From 5feb09f086c524611730ed2677c78387f36e7727 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 10 May 2011 20:14:30 +0000 Subject: [PATCH] * (bug 25262) Fix for minification of hardcoded data: URIs in CSS 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 | 1 + includes/libs/CSSMin.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.18 b/RELEASE-NOTES-1.18 index 649619b6d1..cf3163ac9b 100644 --- a/RELEASE-NOTES-1.18 +++ b/RELEASE-NOTES-1.18 @@ -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. diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index ad65d24435..c0e7811273 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -120,8 +120,9 @@ class CSSMin { self::URL_REGEX . '(?P[^;]*)[\;]?/'; $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; -- 2.20.1