Merge "OutputPage: Ignore protocol-relative urls in transformResourcePath()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 18 Jan 2017 18:43:32 +0000 (18:43 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 18 Jan 2017 18:43:32 +0000 (18:43 +0000)
includes/OutputPage.php
tests/phpunit/includes/OutputPageTest.php

index 211f44b..8fe1285 100644 (file)
@@ -3703,8 +3703,9 @@ class OutputPage extends ContextSource {
                } else {
                        $remotePath = $remotePathPrefix;
                }
-               if ( strpos( $path, $remotePath ) !== 0 ) {
-                       // Path is outside wgResourceBasePath, ignore.
+               if ( strpos( $path, $remotePath ) !== 0 || substr( $path, 0, 2 ) === '//' ) {
+                       // - Path is outside wgResourceBasePath, ignore.
+                       // - Path is protocol-relative. Fixes T155310. Not supported by RelPath lib.
                        return $path;
                }
                $path = RelPath\getRelativePath( $path, $remotePath );
index f0c8f7a..0e83006 100644 (file)
@@ -152,6 +152,9 @@ class OutputPageTest extends MediaWikiTestCase {
                        // Unrelated path with domain component. Ignored.
                        [ 'baseDir' => $baseDir, 'basePath' => '/w', 'https://example.org/files/test.jpg' ],
                        [ 'baseDir' => $baseDir, 'basePath' => '/w', '//example.org/files/test.jpg' ],
+                       // Unrelated path with domain, and empty base path (root mw install). Ignored.
+                       [ 'baseDir' => $baseDir, 'basePath' => '', 'https://example.org/files/test.jpg' ],
+                       [ 'baseDir' => $baseDir, 'basePath' => '', '//example.org/files/test.jpg' ], // T155310
                ];
        }