From: Bartosz DziewoƄski Date: Thu, 27 Feb 2014 13:16:39 +0000 (+0100) Subject: CSSMin: Don't do file_exists on random data in getLocalFileReferences() X-Git-Tag: 1.31.0-rc.0~16672 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=603174ff41425366602358daa68a9fbd50f15b58;p=lhc%2Fweb%2Fwiklou.git CSSMin: Don't do file_exists on random data in getLocalFileReferences() If it's a URL, it obviously can't be a local file; check that first to avoid PHP warnings about malformed paths. Bug: 60960 Change-Id: Id784c089c3de8af79af7524ef5ab5cc2f7b8af9e --- diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index bdb75e80db..344c967cfb 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -158,6 +158,8 @@ production. * (bug 26811) When a DBUnexpectedError occurs, DB server hostnames are now hidden unless $wgShowExceptionDetails is true, and $wgShowDBErrorBacktrace no longer applies in such cases. +* (bug 60960) Avoid doing file_exist() checks on data: URIs, as they cause + warnings to be printed on Windows due to large path length. === Web API changes in 1.23 === * (bug 54884) action=parse&prop=categories now indicates hidden and missing diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index e490e4f41d..e3a3e2c77c 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -79,11 +79,20 @@ class CSSMin { $rFlags = PREG_OFFSET_CAPTURE | PREG_SET_ORDER; if ( preg_match_all( '/' . self::URL_REGEX . '/', $source, $matches, $rFlags ) ) { foreach ( $matches as $match ) { - $file = $path . $match['file'][0]; - // Only proceed if we can access the file + $url = $match['file'][0]; + + // Skip fully-qualified and protocol-relative URLs and data URIs + if ( substr( $url, 0, 2 ) === '//' || parse_url( $url, PHP_URL_SCHEME ) ) { + break; + } + + $file = $path . $url; + // Skip non-existent files if ( file_exists( $file ) ) { - $files[] = $file; + break; } + + $files[] = $file; } } return $files; @@ -246,8 +255,7 @@ class CSSMin { $url = $file . $query; // Skip fully-qualified and protocol-relative URLs and data URIs - $urlScheme = substr( $url, 0, 2 ) === '//' || parse_url( $url, PHP_URL_SCHEME ); - if ( $urlScheme ) { + if ( substr( $url, 0, 2 ) === '//' || parse_url( $url, PHP_URL_SCHEME ) ) { return $url; }