From: Bartosz DziewoƄski Date: Wed, 2 Nov 2016 09:25:40 +0000 (+0100) Subject: CSSMin: Correctly avoid fallbacks when embedding SVG files X-Git-Tag: 1.31.0-rc.0~4976^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=c48e061f677d3f9c59ed543ff0630e926418df5b;p=lhc%2Fweb%2Fwiklou.git CSSMin: Correctly avoid fallbacks when embedding SVG files The check for file existence before checking its MIME type was building the path incorrectly, causing this piece of code to always think the file does not exist. (The code to actually embed the file was correct.) This was not caught by the tests before of a bug in the test code, which cancelled out this one. Bug: T100958 Change-Id: I4469079f41d48052d0a02f98bb1ed02407abd54c --- diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 6e40f4c674..797a438d00 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -319,7 +319,7 @@ class CSSMin { ); $url = $match['file'] . $match['query']; - $file = $local . $match['file']; + $file = "{$local}/{$match['file']}"; if ( !self::isRemoteUrl( $url ) && !self::isLocalUrl( $url ) && file_exists( $file ) diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index 5f5a1e8f01..366714b193 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -129,8 +129,8 @@ class CSSMinTest extends MediaWikiTestCase { * @covers CSSMin::remap */ public function testRemapRemapping( $message, $input, $expectedOutput ) { - $localPath = __DIR__ . '/../../data/cssmin/'; - $remotePath = 'http://localhost/w/'; + $localPath = __DIR__ . '/../../data/cssmin'; + $remotePath = 'http://localhost/w'; $realOutput = CSSMin::remap( $input, $localPath, $remotePath ); $this->assertEquals( $expectedOutput, $realOutput, "CSSMin::remap: $message" );