Skip to content

Commit

Permalink
MDL-29864: Port a patch from upstream minify project to handle spaces…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Andrew Robert Nicols committed Oct 24, 2011
1 parent 3a81b37 commit ffd5e66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/minify/lib/Minify/CSS/Compressor.php
Expand Up @@ -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];
}
}
2 changes: 2 additions & 0 deletions lib/minify/readme_moodle.txt
Expand Up @@ -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.

0 comments on commit ffd5e66

Please sign in to comment.