From d313859b0229f815690f80100391aa9d7d0a9a41 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 3 Mar 2010 22:01:09 +0000 Subject: [PATCH] (Bug 22709) IIS 7 mishandles redirects generated by OutputPage::output() when 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 | 2 ++ includes/GlobalFunctions.php | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1aca2ac4a2..2bacae303c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 , and redirects +* (bug 22709) IIS7 mishandles redirects generated by OutputPage::output() when +the URL contains a colon. == API changes in 1.17 == diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 3a48326751..cd2c00e758 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 ); -- 2.20.1