From: Timo Tijhof Date: Wed, 20 Jun 2012 11:05:03 +0000 (+0200) Subject: CSSMin: Clean up $remote trailing slash fix X-Git-Tag: 1.31.0-rc.0~23262^2 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=90fd3bdea58b5cc7f933e00760463531002942d5;p=lhc%2Fweb%2Fwiklou.git CSSMin: Clean up $remote trailing slash fix * No need to strip them from everywhere all over. This bug is only caused by the presence of a trailing slash on $remote. * To make sure everything still works before and after I added unit tests for CSSMin in Ic9195614acfd, making this dependent on that change. Change-Id: Ia82048a328a056117afe0d653fe22f5429b21f5a --- diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index e9c2badf62..fc75cdcc52 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -152,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]; @@ -159,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