1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-08 07:06:49 +02:00

CSS/Compressor.php : Issue 107 fix

This commit is contained in:
Steve Clay
2009-05-01 02:52:17 +00:00
parent 17a4bc96f1
commit 8020c99ea1
7 changed files with 15 additions and 5 deletions

View File

@@ -176,6 +176,7 @@ class Minify_CSS_Compressor {
*/
protected function _commentCB($m)
{
$hasSurroundingWs = (trim($m[0]) !== $m[1]);
$m = $m[1];
// $m is the comment content w/o the surrounding tokens,
// but the return value will replace the entire comment.
@@ -219,7 +220,11 @@ class Minify_CSS_Compressor {
$this->_inHack = false;
return '/**/';
}
return ''; // remove all other comments
// Issue 107: if there's any surrounding whitespace, it may be important, so
// replace the comment with a single space
return $hasSurroundingWs // remove all other comments
? ' '
: '';
}
/**

View File

@@ -4,3 +4,6 @@
/*! YUI Compressor style comments are preserved */
/* but all other comments are removed */
/* comments that have any surrounding whitespace are replaced by a single space. */
body{ background:#fff/*eef*/ url(/path/to/image.gif) repeat-y; }

View File

@@ -1,2 +1,3 @@
/* YUI Compressor style comments are preserved */
body{background:#fff url(/path/to/image.gif) repeat-y}

View File

@@ -1,4 +1,4 @@
/*\*/a{}.foo{color:red}/**//*\*//*/@import "ie5mac.css";/**//*/*/.foo{display:block}/**//*/*//*/.foo{display:crazy}/**/div{width:140px;width/**/:/**/100px;width:/**/100px}html>/**/body{}div{width:400px;voice-family:"\"}\"";voice-family:inherit;width:300px}div{filter:chroma(color=#aabbcc);filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000)}@media
/*\*/a{}.foo{color:red}/**/ /*\*//*/@import "ie5mac.css";/**/ /*/*/.foo{display:block}/**/ /*/*//*/.foo{display:crazy}/**/ div{width:140px;width/**/:/**/100px;width:/**/100px}html>/**/body{}div{width:400px;voice-family:"\"}\"";voice-family:inherit;width:300px}div{filter:chroma(color=#aabbcc);filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000)}@media
screen{/*\*/* html
div#page{height:1%}/**/}foo{_height:20px;*height:15px}@media
tty{i{content:"\";/*" "*/}}@import 'midpassafter.css';/*"}}/* */p:first-letter {color:red}p:first-line {color:red}
tty{i{content:"\";/*" "*/}}@import 'midpassafter.css';/*"}}/* */ p:first-letter {color:red}p:first-line {color:red}

View File

@@ -10,7 +10,7 @@ if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script
{}/*]]>*/</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">/*<![CDATA[*/(i<1);/*]]>*/</script> <!--[if IE 6]><style type="text/css">/*<![CDATA[*/
/* copyright: you'll need CDATA for this < & */
body{background:white}/*]]>*/</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
hack{}/**//*/*/css
hack{}/**/ /*/*/css
hack{}/**/css
hack{display/**/:/**/none;display:none}</style><link
rel="Shortcut Icon"

View File

@@ -10,7 +10,7 @@ if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script
{}</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">(i<1);</script> <!--[if IE 6]><style type="text/css">
/* copyright: you'll need CDATA for this < & */
body{background:white}</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
hack{}/**//*/*/css
hack{}/**/ /*/*/css
hack{}/**/css
hack{display/**/:/**/none;display:none}</style><link
rel="Shortcut Icon"

View File

@@ -2,3 +2,4 @@
solid #0f7}div#content
h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}}
/* YUI Compressor style comments are preserved */
body{background:#fff url(/path/to/image.gif) repeat-y}