summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
Diffstat (limited to 'system/core')
-rw-r--r--system/core/Output.php11
1 files changed, 8 insertions, 3 deletions
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);
}