Avoid a redirect loop when the request URL is not normalized
authorTim Starling <tstarling@wikimedia.org>
Tue, 10 Jul 2018 07:04:31 +0000 (17:04 +1000)
committerTim Starling <tstarling@wikimedia.org>
Mon, 16 Jul 2018 05:55:59 +0000 (15:55 +1000)
commitf6d582a91ee990de3ba04dad67eba055040a0e3f
tree88a0f9297bc96552a0fae922ac9620cbd0e21612
parent31372c619eb9beb848d14d0c08c567a03cc92660
Avoid a redirect loop when the request URL is not normalized

If the request URL was not normalized, for example having a double slash
in it, this could cause it to fail to match in the PathRouter. But the
canonicalizing redirect was using the normalized URL, causing a redirect
loop exception.

So:

* If the PathRouter fails to match with the original URL, try matching
  against the normalized URL. This allows it to still work for
  normalized URLs with a double slash in the title part of the path.
* Have WebRequest::getFullRequestURL() always return the URL without
  removing dot segments or interpreting double slashes. Just append
  the path to the server.
* Make MediaWikiTest.php use WebRequest instead of FauxRequest, allowing
  it to reproduce the exception in question. Add relevant test.
* Add tests for the new PathRouter behaviour.

Bug: T100782
Change-Id: Ic0f3a0060904abc364f75dae920480b81175d52f
includes/GlobalFunctions.php
includes/PathRouter.php
includes/WebRequest.php
tests/phpunit/includes/MediaWikiTest.php
tests/phpunit/includes/PathRouterTest.php
tests/phpunit/includes/api/format/ApiFormatBaseTest.php