From ffd5e66e0e82dad4bd0fd45f3724934c52fd3425 Mon Sep 17 00:00:00 2001 From: Andrew Robert Nicols Date: Mon, 24 Oct 2011 09:29:52 +0100 Subject: [PATCH] MDL-29864: Port a patch from upstream minify project to handle spaces in font-family names No upstream release of minify with this patch included is available yet, so I've ported just the relevant part of the fixing commit. --- lib/minify/lib/Minify/CSS/Compressor.php | 21 +++++++++++---------- lib/minify/readme_moodle.txt | 2 ++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/minify/lib/Minify/CSS/Compressor.php b/lib/minify/lib/Minify/CSS/Compressor.php index d483b2fed401e..dad700a9c4eb9 100644 --- a/lib/minify/lib/Minify/CSS/Compressor.php +++ b/lib/minify/lib/Minify/CSS/Compressor.php @@ -236,15 +236,16 @@ protected function _commentCB($m) */ protected function _fontFamilyCB($m) { - $m[1] = preg_replace('/ - \\s* - ( - "[^"]+" # 1 = family in double qutoes - |\'[^\']+\' # or 1 = family in single quotes - |[\\w\\-]+ # or 1 = unquoted family - ) - \\s* - /x', '$1', $m[1]); - return 'font-family:' . $m[1] . $m[2]; + // 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 = preg_replace('/\\s+/', ' ', $piece); + $piece = preg_replace('/\\s?,\\s?/', ',', $piece); + } + $out .= $piece; + } + return $out . $m[2]; } } diff --git a/lib/minify/readme_moodle.txt b/lib/minify/readme_moodle.txt index bd798f2d8b277..f7be3f46a4c96 100644 --- a/lib/minify/readme_moodle.txt +++ b/lib/minify/readme_moodle.txt @@ -15,3 +15,5 @@ Changes: * Removed .htaccess - Not needed * Changed config.php - Changed settings to Moodle specific settings incase this ever gets accidentally used. + * Updated lib/Minify/CSS/Compressor.php - Applied an upstream fix for MDL-29864 + to allow usage of unquoted font-familes with spaces in CSS.