CSSMin: Correctly avoid fallbacks when embedding SVG files
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 2 Nov 2016 09:25:40 +0000 (10:25 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 2 Nov 2016 09:26:21 +0000 (10:26 +0100)
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

includes/libs/CSSMin.php
tests/phpunit/includes/libs/CSSMinTest.php

index 6e40f4c..797a438 100644 (file)
@@ -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 )
index 5f5a1e8..366714b 100644 (file)
@@ -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" );