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.
This commit is contained in:
Andrew Robert Nicols 2011-10-24 09:29:52 +01:00
parent 3a81b37617
commit ffd5e66e0e
2 changed files with 13 additions and 10 deletions

View File

@ -236,15 +236,16 @@ class Minify_CSS_Compressor {
*/
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];
}
}

View File

@ -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.