http -> https rewrite: Only replace one http by https
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 26 Apr 2014 20:34:21 +0000 (22:34 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Mon, 28 Apr 2014 19:01:43 +0000 (19:01 +0000)
This avoids changing from
http://de.wikipedia.org/wiki/Spezial:Weblinksuche/http://wikimedia.org
to
https://de.wikipedia.org/wiki/Spezial:Weblinksuche/https://wikimedia.org
instead of
https://de.wikipedia.org/wiki/Spezial:Weblinksuche/http://wikimedia.org

Bug: 63573
Change-Id: Ife5099c3c5a0e943bb08b81be5d5669d0e02be17

includes/Wiki.php

index 2ef1382..aed1f65 100644 (file)
@@ -542,7 +542,7 @@ class MediaWiki {
                        $request->getProtocol() == 'http'
                ) {
                        $oldUrl = $request->getFullRequestURL();
-                       $redirUrl = str_replace( 'http://', 'https://', $oldUrl );
+                       $redirUrl = preg_replace( '#^http://#', 'https://', $oldUrl );
 
                        if ( $request->wasPosted() ) {
                                // This is weird and we'd hope it almost never happens. This