summaryrefslogtreecommitdiffstats
path: root/system/core/Output.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-04-05 13:28:04 +0200
committerAndrey Andreev <narf@bofh.bg>2013-04-05 13:28:04 +0200
commitccdd4290aca2ddb3c64ca3db57e1da5c34537a6a (patch)
tree54c0df4bbcfe7d39c2ab30fb0ac87db2fdaacec3 /system/core/Output.php
parent0e4237f8fb01320fb7cc87b1fb93a552630505d6 (diff)
Fix #2387
Diffstat (limited to 'system/core/Output.php')
-rw-r--r--system/core/Output.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/system/core/Output.php b/system/core/Output.php
index 3320ae154..8f4690052 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -841,9 +841,8 @@ class CI_Output {
$output = substr_replace($output, '', 0, $pos);
// Remove closing tag and save it for later
- $end_pos = strlen($output);
$pos = strpos($output, '</');
- $closing_tag = substr($output, $pos, $end_pos);
+ $closing_tag = substr($output, $pos, strlen($output));
$output = substr_replace($output, '', $pos);
}
@@ -852,7 +851,16 @@ class CI_Output {
// Remove spaces around curly brackets, colons,
// semi-colons, parenthesis, commas
- $output = preg_replace('!\s*(:|;|,|}|{|\(|\))\s*!i', '$1', $output);
+ $chunks = preg_split('/([\'|"]).+(?![^\\\]\\1)\\1/iU', $output, -1, PREG_SPLIT_OFFSET_CAPTURE);
+ for ($i = count($chunks) - 1; $i >= 0; $i--)
+ {
+ $output = substr_replace(
+ $output,
+ preg_replace('/\s*(:|;|,|}|{|\(|\))\s*/i', '$1', $chunks[$i][0]),
+ $chunks[$i][1],
+ strlen($chunks[$i][0])
+ );
+ }
// Replace tabs with spaces
// Replace carriage returns & multiple new lines with single new line