From 5bb7056368b316547a5a8c9067ffa18ad7626a3b Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sun, 9 Aug 2009 23:17:14 -0600 Subject: [PATCH] Support IE conditional comments --- .../Horde/Text/Filter/JavascriptMinify/JsMin.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/JavascriptMinify/JsMin.php b/framework/Text_Filter/lib/Horde/Text/Filter/JavascriptMinify/JsMin.php index 8539efce0..7b5333eeb 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/JavascriptMinify/JsMin.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/JavascriptMinify/JsMin.php @@ -185,6 +185,7 @@ class Horde_Text_Filter_JavascriptMinify_JsMin protected function _next() { + $c = $this->_get(); if ($c !== '/') { @@ -193,21 +194,37 @@ class Horde_Text_Filter_JavascriptMinify_JsMin switch ($this->_peek()) { case '/': + $comment = ''; + while (true) { $c = $this->_get(); + $comment .= $c; if (ord($c) <= self::ORD_LF) { + // IE conditional comment + if (preg_match('/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment)) { + return '/' . $comment; + } + return $c; } } case '*': + $comment = ''; $this->_get(); while (true) { - switch($this->_get()) { + $get = $this->_get(); + switch ($get) { case '*': if ($this->_peek() === '/') { $this->_get(); + + // IE conditional comment + if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) { + return '/*' . $comment . '*/'; + } + return ' '; } break; @@ -215,6 +232,8 @@ class Horde_Text_Filter_JavascriptMinify_JsMin case null: throw new Exception('Unterminated comment.'); } + + $comment .= $get; } } -- 2.11.0