From 9c39a2a23c81da0d36070a8cb030ed076cf69bec Mon Sep 17 00:00:00 2001 From: Thomas BrĂ¼derli Date: Fri, 30 Mar 2012 16:19:49 +0000 Subject: Make javascript delivery unicode-safe --- itjs.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'itjs.php') diff --git a/itjs.php b/itjs.php index 03073e9..f819cab 100644 --- a/itjs.php +++ b/itjs.php @@ -33,7 +33,7 @@ foreach ($files as $file) { ob_start(); # Needs to capture inside loop to guarantee file order if (!(it::match('W3C_CSS_Validator', $_SERVER['HTTP_USER_AGENT']) && it::match('jquery-ui\.css', $file))) - $data .= it::replace(array('^1$' => ""), @include($file)); + $data .= it::replace(array('^1$' => ""), @include($file), array('utf8' => false)); $data .= ob_get_clean(); } @@ -50,9 +50,8 @@ else if (it::match('\.css', $_SERVER['PHP_SELF'])) $data .= "\n#it_boot_dom { display:none }\n"; # Append magic style for it_boot if (!it::match('^devel', $GLOBALS['ULTRASERVERTYPE'])) $data = it::replace(array('[ \t]*([{};])[ \t]*' => '$1', '/\*.*?\*/' => ""), $data); - if (it::match('W3C_CSS_Validator', $_SERVER['HTTP_USER_AGENT']) || EDC('w3c')) { + if (it::match('W3C_CSS_Validator', $_SERVER['HTTP_USER_AGENT']) || EDC('w3c')) $data = it::replace(array('@-.*' => "", 'background[^;}]*(gradient|rgba)[^;}]*;?' => "", '(filter:\s*(progid|none)|text-overflow:|zoom:|-webkit-|display:-moz-|-moz-|-o-|cursor:|border-radius:|behavior:|\w+:expression)[^;}]*;?' => "", 'html\.ie6.*' => "", '([^/])\*(\w)' => '$1$2'), $data); - } } else if (it::match('\.htc$', $file)) { @@ -64,7 +63,8 @@ else if (!it::match('\.html$', $file)) if ($_REQUEST['boot'] && !$_REQUEST['retry']) ob_start('ob_gzhandler'); - header("Content-Type: application/x-javascript; charset=iso-8859-1"); + $charset = ini_get('default_charset') ?: 'iso-8859-1'; + header("Content-Type: application/x-javascript; charset=$charset"); } @header("Etag: $checksum"); @@ -80,7 +80,7 @@ if ($checksum != $_SERVER['HTTP_IF_NONE_MATCH']) { $data .= "window.it_boot_init();\n"; if (!$_REQUEST['script']) - $data = sprintf("/*sln:%d*/\n%s/*eln:%d*/", strlen($data), strtr($data, array('%' => "%25", '.' => "%2e", 'e' => "%65", 'i' => "%69")), strlen($data)); # Protect from Firewalls/Proxies altering Javascript source code + $data = sprintf("/*sln:%d*/\n%s/*eln:%d*/", grapheme_strlen($data), strtr($data, array('%' => "%25", '.' => "%2e", 'e' => "%65", 'i' => "%69")), grapheme_strlen($data)); # Protect from Firewalls/Proxies altering Javascript source code } echo it_untaint($data); -- cgit v1.2.3