Browse files

Better fix for Issue 210

  • Loading branch information...
1 parent 1fed7e4 commit 5002cd5fa768d55bcc4b51cf5ba7767751e6fabc @mrclay mrclay committed Jun 23, 2011
View
14 min/lib/Minify/CSS/Compressor.php
@@ -236,14 +236,16 @@ protected function _commentCB($m)
*/
protected function _fontFamilyCB($m)
{
- $pieces = preg_split('@(\'[^\']+\'|"[^"]+")@', $m[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- foreach ($pieces as $i => $piece) {
+ // Issue 210: must not eliminate WS between words in unquoted families
+ $pieces = preg_split('/(\'[^\']+\'|"[^"]+")/', $m[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ $out = 'font-family:';
+ while (null !== ($piece = array_shift($pieces))) {
if ($piece[0] !== '"' && $piece[0] !== "'") {
- $piece = trim(preg_replace('@\\s+@', ' ', $piece));
- $piece = preg_replace('@\\s*,\\s*@', ',', $piece);
- $pieces[$i] = $piece;
+ $piece = preg_replace('/\\s+/', ' ', $piece);
+ $piece = preg_replace('/\\s?,\\s?/', ',', $piece);
}
+ $out .= $piece;
}
- return 'font-family:' . implode('', $pieces) . $m[2];
+ return $out . $m[2];
}
}
View
2 min_unit_tests/_test_files/css/styles.css
@@ -5,7 +5,7 @@
@import url( /more.css );
body, td, th {
- font-family: Verdana , "Bitstream Vera Sans" , sans-serif ;
+ font-family: Verdana , "Bitstream Vera Sans" , Arial Narrow, sans-serif ;
font-size : 12px;
}
View
2 min_unit_tests/_test_files/css/styles.min.css
@@ -1,3 +1,3 @@
-@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
+@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",Arial Narrow,sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
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}}
View
2 min_unit_tests/_test_files/importProcessor/output.css
@@ -6,7 +6,7 @@
@import url(/more.css);
body, td, th {
- font-family: Verdana , "Bitstream Vera Sans" , sans-serif ;
+ font-family: Verdana , "Bitstream Vera Sans" , Arial Narrow, sans-serif ;
font-size : 12px;
}
View
2 min_unit_tests/_test_files/minify/minified.css
@@ -1,4 +1,4 @@
-@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
+@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",Arial Narrow,sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
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 */
View
2 min_unit_tests/test_Minify_CSS.php
@@ -19,7 +19,7 @@ function test_CSS()
$d->close();
foreach ($list as $item) {
-
+
$options = array();
if ($item === 'paths_prepend') {
$options = array('prependRelativePath' => '../');
View
2 min_unit_tests/test_Minify_JS_ClosureCompiler.php
@@ -16,7 +16,7 @@ function addOne(input) {
window.undefined = undefined;
})(window);
";
- $minExpected = "(function(a,b){a.addOne=function(c){return 1+c};a.undefined=b})(window);";
+ $minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);";
$minOutput = Minify_JS_ClosureCompiler::minify($src);
if (false !== strpos($minOutput, 'Error(22): Too many compiles')) {
echo "!NOTE: Too many recent calls to Closure Compiler API to test.\n";

0 comments on commit 5002cd5

Please sign in to comment.