From: Bartosz Dziewoński Date: Thu, 20 Aug 2015 16:38:04 +0000 (+0200) Subject: Do not encode "'" as %27 (redirect loop in Opera 12) X-Git-Tag: 1.31.0-rc.0~10129 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=a89a21990e9d696487c4da72f88f765e2b4b1c34;p=lhc%2Fweb%2Fwiklou.git Do not encode "'" as %27 (redirect loop in Opera 12) Similar to 7b4df0e12e36332fc2b303d7dac2295f8d36c888, but for apostrophe instead of tilde and for Opera instead of Chrome. Bug: T106793 Change-Id: Ic54390434cebcc76a6c8ab49acc164d36e0cdff6 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index b853d0781b..68e16357c1 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -404,14 +404,15 @@ function wfRandomString( $length = 32 ) { * RFC 1738 says ~ is unsafe, however RFC 3986 considers it an unreserved * character which should not be encoded. More importantly, google chrome * always converts %7E back to ~, and converting it in this function can - * cause a redirect loop (T105265). + * cause a redirect loop (T105265). Similarly, encoding ' causes a + * redirect loop on Opera 12 (T106793). * * But + is not safe because it's used to indicate a space; &= are only safe in - * paths and not in queries (and we don't distinguish here); ' seems kind of - * scary; and urlencode() doesn't touch -_. to begin with. Plus, although / + * paths and not in queries (and we don't distinguish here); + * and urlencode() doesn't touch -_. to begin with. Plus, although / * is reserved, we don't care. So the list we unescape is: * - * ;:@$!*(),/~ + * ;:@$!*'(),/~ * * However, IIS7 redirects fail when the url contains a colon (Bug 22709), * so no fancy : for IIS7. @@ -430,7 +431,7 @@ function wfUrlencode( $s ) { } if ( is_null( $needle ) ) { - $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F', '%7E' ); + $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%27', '%28', '%29', '%2C', '%2F', '%7E' ); if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) { @@ -441,7 +442,7 @@ function wfUrlencode( $s ) { $s = urlencode( $s ); $s = str_ireplace( $needle, - array( ';', '@', '$', '!', '*', '(', ')', ',', '/', '~', ':' ), + array( ';', '@', '$', '!', '*', '\'', '(', ')', ',', '/', '~', ':' ), $s ); diff --git a/includes/Linker.php b/includes/Linker.php index d6a4056f02..4d3f3ce87e 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -939,7 +939,10 @@ class Linker { $href = self::getUploadUrl( $title, $query ); - return '' . $encLabel . ''; } diff --git a/resources/src/mediawiki/mediawiki.util.js b/resources/src/mediawiki/mediawiki.util.js index 2a3542ceaa..1d11d8c8d8 100644 --- a/resources/src/mediawiki/mediawiki.util.js +++ b/resources/src/mediawiki/mediawiki.util.js @@ -78,6 +78,7 @@ .replace( /%24/g, '$' ) .replace( /%21/g, '!' ) .replace( /%2A/g, '*' ) + .replace( /%27/g, '\'' ) .replace( /%28/g, '(' ) .replace( /%29/g, ')' ) .replace( /%2C/g, ',' ) diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index aa8c9c89c6..9cada85c82 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -5711,7 +5711,7 @@ Plain ''italic'''s plain ### ### Tables ### -### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables +### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User's_Guide:_Using_tables ### # This should not produce
as
@@ -7368,7 +7368,7 @@ Link containing double-single-quotes '' (bug 4598) !! wikitext [[Lista d''e paise d''o munno]] !! html/php -

Lista d''e paise d''o munno +

Lista d''e paise d''o munno

!! html/parsoid

Lista d''e paise d''o munno

@@ -7405,10 +7405,10 @@ Link with double quotes in title part (literal) and alternate part (interpreted) [[''Pentecoste''|''Pentecoste'']] !! html/php -

File:Denys Savchenko Pentecoste.jpg -

''Pentecoste'' -

Pentecoste -

Pentecoste +

File:Denys Savchenko Pentecoste.jpg +

''Pentecoste'' +

Pentecoste +

Pentecoste

!! html/parsoid

@@ -14033,7 +14033,7 @@ Link to category !! wikitext [[:Category:MediaWiki User's Guide]] !! html -

Category:MediaWiki User's Guide +

Category:MediaWiki User's Guide

!! end @@ -14044,7 +14044,7 @@ cat !! wikitext [[Category:MediaWiki User's Guide]] !! html -MediaWiki User's Guide +MediaWiki User's Guide !! end !! test @@ -14063,7 +14063,7 @@ cat !! wikitext [[Category:MediaWiki User's Guide|Foo]] !! html -MediaWiki User's Guide +MediaWiki User's Guide !! end !! test @@ -14073,7 +14073,7 @@ cat !! wikitext [[Category:MediaWiki User's Guide|MediaWiki User's Guide]] !! html -MediaWiki User's Guide +MediaWiki User's Guide !! end !! test @@ -19025,7 +19025,7 @@ language=sr cat !! wikitext [[Category:МедиаWики Усер'с Гуиде]] !! html -MediaWiki User's Guide +MediaWiki User's Guide !! end @@ -20981,7 +20981,7 @@ File:foobar.jpg|caption|alt=galleryalt|link=" onclick="alert('malicious javascri !! html