} 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 );
// 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
];
}