(bug NNNNN) Rewrite most of wfExpandUrl() to handle protocol-relative URLs properly...
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 27 Jul 2011 08:21:40 +0000 (08:21 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 27 Jul 2011 08:21:40 +0000 (08:21 +0000)
commite2b9cc88998e85225267f1037dda31af6a76d2c6
treead9b017ed0e1605b9b85fb1e14d6af09be7228c7
parentedf1143de1410d7ccf355c29b2cdd05f58cef6e5
(bug NNNNN) Rewrite most of wfExpandUrl() to handle protocol-relative URLs properly and more flexibly
* Fix a bug in rNNNNN where URLs like '/wiki/Foo' weren't expanded completely if $wgServer was protocol-relative. This caused bug NNNNN.
* Add an optional second parameter to wfExpandUrl(), which takes one the PROT_* constants. This allows the caller to determine which protocol should be used if the given URL is protocol-relative, or the given URL is domain-relative but $wgServer is protocol-relative. The options are PROT_HTTP (use http), PROT_HTTPS (use https), PROT_RELATIVE (keep the URL as protocol-relative), and PROT_CURRENT (use http if the current request is http, or https if the current request is https; this is the default).
* Factor the protocol/port detection part of WebRequest::detectServer() out into detectProtocolAndStdPort(), and add detectProtocol() as a wrapper. The latter is used by wfExpandUrl() in PROT_CURRENT mode.
* Rewrite the test suite to test all possible combinations of $wgServer, $defaultProto, $url and HTTP/HTTPS mode. This means the test suite now has 120 test cases rather than 4.
includes/GlobalFunctions.php
includes/WebRequest.php
tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php