diff options
Diffstat (limited to 'includes/libs/CSSMin.php')
-rw-r--r-- | includes/libs/CSSMin.php | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 4f4b28bb..fc75cdcc 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -1,5 +1,7 @@ <?php /** + * Minification of CSS stylesheets. + * * Copyright 2010 Wikimedia Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -12,12 +14,6 @@ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. - */ - -/** - * Transforms CSS data - * - * This class provides minification, URL remapping, URL extracting, and data-URL embedding. * * @file * @version 0.1.1 -- 2010-09-11 @@ -25,6 +21,12 @@ * @copyright Copyright 2010 Wikimedia Foundation * @license http://www.apache.org/licenses/LICENSE-2.0 */ + +/** + * Transforms CSS data + * + * This class provides minification, URL remapping, URL extracting, and data-URL embedding. + */ class CSSMin { /* Constants */ @@ -150,6 +152,13 @@ class CSSMin { $offset = $match[0][1] + strlen( $match[0][0] ) + $lengthIncrease; continue; } + + // Guard against double slashes, because "some/remote/../foo.png" + // resolves to "some/remote/foo.png" on (some?) clients (bug 27052). + if ( substr( $remote, -1 ) == '/' ) { + $remote = substr( $remote, 0, -1 ); + } + // Shortcuts $embed = $match['embed'][0]; $pre = $match['pre'][0]; @@ -157,10 +166,9 @@ class CSSMin { $query = $match['query'][0]; $url = "{$remote}/{$match['file'][0]}"; $file = "{$local}/{$match['file'][0]}"; - // bug 27052 - Guard against double slashes, because foo//../bar - // apparently resolves to foo/bar on (some?) clients - $url = preg_replace( '#([^:])//+#', '\1/', $url ); + $replacement = false; + if ( $local !== false && file_exists( $file ) ) { // Add version parameter as a time-stamp in ISO 8601 format, // using Z for the timezone, meaning GMT |