From 0bba6434f0ba3d6b1f677233c2e3c8f37b3195cc Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Sun, 22 Sep 2013 02:09:36 -0400 Subject: Fixes Issue 2637 more elegant way to make sure that the comment is not in a js string var --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Output.php') diff --git a/system/core/Output.php b/system/core/Output.php index 7c2a64d24..b5955c008 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -847,7 +847,7 @@ class CI_Output { } // Remove CSS comments - $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!i', '', $output); + $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/(?!.*?("|\'))!i', '', $output); // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) -- cgit v1.2.3-24-g4f1b From 6d917858b5ffd012bd85a0062d511d261cd6df2d Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Mon, 23 Sep 2013 23:47:26 -0400 Subject: fix #2637 cleaned up the regex to remove extra qualifiers used character sets where possible for clarity main expression optimized --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Output.php') diff --git a/system/core/Output.php b/system/core/Output.php index b5955c008..7a5fb66f6 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -847,7 +847,7 @@ class CI_Output { } // Remove CSS comments - $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/(?!.*?("|\'))!i', '', $output); + $output = preg_replace('!/\*([^/][^*]*\*)*/(?!.+?["\'])!i', '', $output); // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) -- cgit v1.2.3-24-g4f1b From a442bc2bced3bd9359548c376f99027d5334a1c7 Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Wed, 2 Oct 2013 23:16:51 -0400 Subject: re-fixes #2637 delimiter used for regex bounds found in neg. lookahead causes error using @ delimiter now for this expression --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Output.php') diff --git a/system/core/Output.php b/system/core/Output.php index 7a5fb66f6..04209d920 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -847,7 +847,7 @@ class CI_Output { } // Remove CSS comments - $output = preg_replace('!/\*([^/][^*]*\*)*/(?!.+?["\'])!i', '', $output); + $output = preg_replace('@/\*([^/][^*]*\*)*/(?!.+?["\'])@i', '', $output); // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) -- cgit v1.2.3-24-g4f1b From 6614367f62d2cbd9e8f979c9349cd5474b035866 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 22 Oct 2013 15:00:11 +0300 Subject: Fix CSS minifier --- system/core/Output.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/core/Output.php') diff --git a/system/core/Output.php b/system/core/Output.php index 04209d920..719c43256 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -909,12 +909,12 @@ class CI_Output { $next = $array_output[$key + 1]; // Strip spaces preceded/followed by a non-ASCII character - // or not preceded/followed by an alphanumeric - // or not preceded/followed \ $ and _ + // that are not preceded/followed by an alphanumeric character, + // '\', '$', '_', '.' and '#' if ((preg_match('/^[\x20-\x7f]*$/D', $next) OR preg_match('/^[\x20-\x7f]*$/D', $prev)) && ( ! ctype_alnum($next) OR ! ctype_alnum($prev)) - && ! in_array($next, array('\\', '_', '$'), TRUE) - && ! in_array($prev, array('\\', '_', '$'), TRUE) + && ! in_array($next, array('\\', '_', '$', '.', '#'), TRUE) + && ! in_array($prev, array('\\', '_', '$', '.', '#'), TRUE) ) { unset($array_output[$key]); -- cgit v1.2.3-24-g4f1b From 6a424902ba0dbd59de2dd6e69bbf9e73d10c083d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Oct 2013 14:16:18 +0200 Subject: An alternative to CI_Output::_minify_script_style() using more efficient regexp patterns --- system/core/Output.php | 102 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 5 deletions(-) (limited to 'system/core/Output.php') diff --git a/system/core/Output.php b/system/core/Output.php index 719c43256..cae1347bc 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -740,13 +740,13 @@ class CI_Output { preg_match_all('{}msU', $output, $style_clean); foreach ($style_clean[0] as $s) { - $output = str_replace($s, $this->_minify_script_style($s, TRUE), $output); + $output = str_replace($s, $this->_minify_js_css($s, 'css', TRUE), $output); } // Minify the javascript in