* (bug 25262) Fix for minification of hardcoded data: URIs in CSS
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 10 May 2011 20:14:30 +0000 (20:14 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 10 May 2011 20:14:30 +0000 (20:14 +0000)
CSSMin::minify()'s processing of url references for path adjustment or embedding had excluded explicit fully-qualified http: and https: URLs, but was damaging others such as data: URIs that were actually hardcoded into the original CSS.
This was affecting styles used on no.wikipedia.org which embedded a few icons directly into the style sheet.
Now checking for any URL scheme rather than hardcoding a check for http & https.

RELEASE-NOTES-1.18
includes/libs/CSSMin.php

index 649619b..cf3163a 100644 (file)
@@ -250,6 +250,7 @@ production.
 * (bug 28076) Thumbnail height limited to 360 pixels on Special:Listfiles
 * (bug 22227) Special:Listfiles no longer throws an error on bogus file entries
 * (bug 19408) user_properties.up_property: 32 bytes is not enough.
+* (bug 25262) Fix for minification of hardcoded data: URIs in CSS
 
 === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result.
index ad65d24..c0e7811 100644 (file)
@@ -120,8 +120,9 @@ class CSSMin {
                        self::URL_REGEX . '(?P<post>[^;]*)[\;]?/';
                $offset = 0;
                while ( preg_match( $pattern, $source, $match, PREG_OFFSET_CAPTURE, $offset ) ) {
-                       // Skip absolute URIs
-                       if ( preg_match( '/^https?:\/\//', $match['file'][0] ) ) {
+                       // Skip fully-qualified URLs and data URIs
+                       $urlScheme = parse_url( $match['file'][0], PHP_URL_SCHEME );
+                       if ( $urlScheme ) {
                                // Move the offset to the end of the match, leaving it alone
                                $offset = $match[0][1] + strlen( $match[0][0] );
                                continue;