(Bug 22709) IIS 7 mishandles redirects generated by OutputPage::output() when
authorPlatonides <platonides@users.mediawiki.org>
Wed, 3 Mar 2010 22:01:09 +0000 (22:01 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Wed, 3 Mar 2010 22:01:09 +0000 (22:01 +0000)
the URL contains a colon.
Avoid tinifying colons for IIS 7.

It's a pity how it pollutes a clean function like wfUrlencode.

RELEASE-NOTES
includes/GlobalFunctions.php

index 1aca2ac..2bacae3 100644 (file)
@@ -36,6 +36,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   when the address changed
 * (bug 22664) Special:Userrights now accepts '0' as a valid user name
 * (bug 5210) preload parser now parses <noinclude>, <includeonly> and redirects
+* (bug 22709) IIS7 mishandles redirects generated by OutputPage::output() when 
+the URL contains a colon.
 
 == API changes in 1.17 ==
 
index 3a48326..cd2c00e 100644 (file)
@@ -299,16 +299,27 @@ function wfRandom() {
  *
  * ;:@$!*(),/
  *
+ * However, IIS7 redirects fail when the url contains a colon (Bug 22709), 
+ * so no fancy : for IIS7.
+ * 
  * %2F in the page titles seems to fatally break for some reason.
  *
  * @param $s String:
  * @return string
 */
 function wfUrlencode( $s ) {
+       static $needle;
+       if ( is_null( $needle ) ) {
+               $needle = array( '%3B','%40','%24','%21','%2A','%28','%29','%2C','%2F' );
+               if (! isset($_SERVER['SERVER_SOFTWARE']) || ( strpos($_SERVER['SERVER_SOFTWARE'], "Microsoft-IIS/7") === false)) {
+                       $needle[] = '%3A';
+               }
+       }               
+       
        $s = urlencode( $s );
        $s = str_ireplace(
-               array( '%3B','%3A','%40','%24','%21','%2A','%28','%29','%2C','%2F' ),
-               array(   ';',  ':',  '@',  '$',  '!',  '*',  '(',  ')',  ',',  '/' ),
+               $needle,
+               array( ';',  '@',  '$',  '!',  '*',  '(',  ')',  ',',  '/',  ':' ),
                $s
        );