From 67e643a475a37c53267d0f43b2c2d67efd907014 Mon Sep 17 00:00:00 2001 From: judge Date: Tue, 10 Sep 2013 13:59:46 +0200 Subject: fixed error in finding closing tag --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 06d7a866b..7bfb8cebe 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -841,7 +841,7 @@ class CI_Output { $output = substr_replace($output, '', 0, $pos); // Remove closing tag and save it for later - $pos = strpos($output, ' Date: Tue, 10 Sep 2013 14:54:47 +0200 Subject: Removed unnecessary parameter --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 7bfb8cebe..e323385ba 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -842,7 +842,7 @@ class CI_Output { // Remove closing tag and save it for later $pos = strrpos($output, ' Date: Tue, 10 Sep 2013 16:13:27 +0200 Subject: Improved detecting whether the pointer is in a string or not --- system/core/Output.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index e323385ba..5272ba662 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -849,6 +849,26 @@ class CI_Output { // Remove CSS comments $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!i', '', $output); + // Remove Javascript inline comments + if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) { + $lines = preg_split('/((\r?\n)|(\n?\r))/',$output); + foreach ($lines as &$line){ + $in_string = $in_dstring = FALSE; + $len = strlen($line); + for ($i=0; $i<$len; $i++){ + if ( !$in_string && !$in_dstring && substr($line,$i,2)==='//'){ + $line = substr($line,0,$i); + break; + } + if ( $line[$i]==='"' ) + $in_dstring = ! $in_dstring; + if ( $line[$i]==="'" ) + $in_string = ! $in_string; + } + } + $output = implode("\n",$lines); + } + // Remove spaces around curly brackets, colons, // semi-colons, parenthesis, commas $chunks = preg_split('/([\'|"]).+(?![^\\\]\\1)\\1/iU', $output, -1, PREG_SPLIT_OFFSET_CAPTURE); @@ -899,11 +919,11 @@ class CI_Output { } } - if ($value === "'") + if ($value === "'" && ! $in_dstring) { $in_string = ! $in_string; } - elseif ($value === '"') + elseif ($value === '"' && ! $in_string) { $in_dstring = ! $in_dstring; } -- cgit v1.2.3-24-g4f1b From f57ecc141e072473c73630af29ffe06be25e850c Mon Sep 17 00:00:00 2001 From: judge Date: Tue, 10 Sep 2013 16:18:14 +0200 Subject: Remove Javascript inline comments + improved detecting whether the pointer is in a string or not --- system/core/Output.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 5272ba662..ec82ae7e8 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -856,14 +856,14 @@ class CI_Output { $in_string = $in_dstring = FALSE; $len = strlen($line); for ($i=0; $i<$len; $i++){ - if ( !$in_string && !$in_dstring && substr($line,$i,2)==='//'){ + if ( ! $in_string && ! $in_dstring && substr($line,$i,2) === '//'){ $line = substr($line,0,$i); break; } - if ( $line[$i]==='"' ) - $in_dstring = ! $in_dstring; - if ( $line[$i]==="'" ) + if ( $line[$i]==="'" && ! $in_dstring ) $in_string = ! $in_string; + else if ( $line[$i]==='"' && ! $in_string ) + $in_dstring = ! $in_dstring; } } $output = implode("\n",$lines); -- cgit v1.2.3-24-g4f1b From c7df348233227ecf490ef26795022af6cd26807c Mon Sep 17 00:00:00 2001 From: judge Date: Tue, 10 Sep 2013 16:24:07 +0200 Subject: Fixed coding style --- system/core/Output.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index ec82ae7e8..355a139d5 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -850,23 +850,27 @@ class CI_Output { $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!i', '', $output); // Remove Javascript inline comments - if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) { - $lines = preg_split('/((\r?\n)|(\n?\r))/',$output); - foreach ($lines as &$line){ + if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) + { + $lines = preg_split('/((\r?\n)|(\n?\r))/', $output); + foreach ($lines as &$line) + { $in_string = $in_dstring = FALSE; $len = strlen($line); - for ($i=0; $i<$len; $i++){ - if ( ! $in_string && ! $in_dstring && substr($line,$i,2) === '//'){ - $line = substr($line,0,$i); + for ($i=0; $i<$len; $i++) + { + if ( ! $in_string && ! $in_dstring && substr($line, $i, 2) === '//') + { + $line = substr($line, 0, $i); break; } - if ( $line[$i]==="'" && ! $in_dstring ) + if ($line[$i] === "'" && ! $in_dstring) $in_string = ! $in_string; - else if ( $line[$i]==='"' && ! $in_string ) + elseif ($line[$i] === '"' && ! $in_string) $in_dstring = ! $in_dstring; } } - $output = implode("\n",$lines); + $output = implode("\n", $lines); } // Remove spaces around curly brackets, colons, -- cgit v1.2.3-24-g4f1b From c5768dbab1f026db1bc3aa3908454eaecbc9006c Mon Sep 17 00:00:00 2001 From: judge Date: Thu, 12 Sep 2013 14:43:43 +0200 Subject: Fixed coding style --- system/core/Output.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 355a139d5..7c2a64d24 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -852,24 +852,29 @@ class CI_Output { // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) { - $lines = preg_split('/((\r?\n)|(\n?\r))/', $output); + $lines = preg_split('/\r?\n|\n?\r/', $output); foreach ($lines as &$line) { $in_string = $in_dstring = FALSE; - $len = strlen($line); - for ($i=0; $i<$len; $i++) + for ($i = 0, $len = strlen($line); $i < $len; $i++) { if ( ! $in_string && ! $in_dstring && substr($line, $i, 2) === '//') { $line = substr($line, 0, $i); break; } + if ($line[$i] === "'" && ! $in_dstring) + { $in_string = ! $in_string; + } elseif ($line[$i] === '"' && ! $in_string) + { $in_dstring = ! $in_dstring; + } } } + $output = implode("\n", $lines); } -- cgit v1.2.3-24-g4f1b