X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FPathRouterTest.php;h=d8916751c0815462b3274aaf8312bcda90f93d98;hp=15c47917bb665e7bfbaa345b1af0f496918ec3d4;hb=214b37ff07f3fde89430297b2a857750a56ae205;hpb=0df3355fba2fb0cfc2ab277036ca4352b9c56375 diff --git a/tests/phpunit/includes/PathRouterTest.php b/tests/phpunit/includes/PathRouterTest.php index 15c47917bb..d8916751c0 100644 --- a/tests/phpunit/includes/PathRouterTest.php +++ b/tests/phpunit/includes/PathRouterTest.php @@ -145,6 +145,58 @@ class PathRouterTest extends MediaWikiTestCase { [ 'title' => "Title_With Space" ] ], + // Double slash and dot expansion + 'Double slash in prefix' => [ + '/wiki/$1', + '//wiki/Foo', + [ 'title' => 'Foo' ] + ], + 'Double slash at start of $1' => [ + '/wiki/$1', + '/wiki//Foo', + [ 'title' => '/Foo' ] + ], + 'Double slash in middle of $1' => [ + '/wiki/$1', + '/wiki/.hack//SIGN', + [ 'title' => '.hack//SIGN' ] + ], + 'Dots removed 1' => [ + '/wiki/$1', + '/x/../wiki/Foo', + [ 'title' => 'Foo' ] + ], + 'Dots removed 2' => [ + '/wiki/$1', + '/./wiki/Foo', + [ 'title' => 'Foo' ] + ], + 'Dots retained 1' => [ + '/wiki/$1', + '/wiki/../wiki/Foo', + [ 'title' => '../wiki/Foo' ] + ], + 'Dots retained 2' => [ + '/wiki/$1', + '/wiki/./Foo', + [ 'title' => './Foo' ] + ], + 'Triple slash' => [ + '/wiki/$1', + '///wiki/Foo', + [ 'title' => 'Foo' ] + ], + // '..' only traverses one slash, see e.g. RFC 3986 + 'Dots traversing double slash 1' => [ + '/wiki/$1', + '/a//b/../../wiki/Foo', + [] + ], + 'Dots traversing double slash 2' => [ + '/wiki/$1', + '/a//b/../../../wiki/Foo', + [ 'title' => 'Foo' ] + ], ]; // Make sure the router doesn't break on special characters like $ used in regexp replacements