From 8477b1b277c03c862ef283d0b2f3b968401dd442 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 10 Sep 2015 15:23:07 +0000 Subject: [PATCH] Revert "Do not encode "'" as %27 (redirect loop in Opera 12)" This seems to cause redirect loops in current Firefox instead. This reverts commit a89a21990e9d696487c4da72f88f765e2b4b1c34. Bug: T106793 Change-Id: I18fac8ab0f94e2df8476131b132c9866902a02c4 --- includes/GlobalFunctions.php | 13 +++++----- includes/Linker.php | 5 +--- resources/src/mediawiki/mediawiki.util.js | 1 - tests/parser/parserTests.txt | 24 +++++++++---------- .../GlobalFunctions/wfUrlencodeTest.php | 7 ++++-- tests/phpunit/includes/LinkerTest.php | 2 +- .../mediawiki/mediawiki.jqueryMsg.test.js | 2 +- .../mediawiki/mediawiki.util.test.js | 7 +++--- 8 files changed, 30 insertions(+), 31 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 68e16357c1..b853d0781b 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -404,15 +404,14 @@ 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). Similarly, encoding ' causes a - * redirect loop on Opera 12 (T106793). + * cause a redirect loop (T105265). * * 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); - * and urlencode() doesn't touch -_. to begin with. Plus, although / + * 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 / * 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. @@ -431,7 +430,7 @@ function wfUrlencode( $s ) { } if ( is_null( $needle ) ) { - $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%27', '%28', '%29', '%2C', '%2F', '%7E' ); + $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F', '%7E' ); if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) { @@ -442,7 +441,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 4d3f3ce87e..d6a4056f02 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -939,10 +939,7 @@ class Linker { $href = self::getUploadUrl( $title, $query ); - // @todo FIXME: If we don't to escape apostrophes (single quotes) here (using ENT_QUOTES), - // then double apostrophes will be parsed as italics somewhere later in the parser, - // and break everything horribly - return '' . $encLabel . ''; } diff --git a/resources/src/mediawiki/mediawiki.util.js b/resources/src/mediawiki/mediawiki.util.js index 1d11d8c8d8..2a3542ceaa 100644 --- a/resources/src/mediawiki/mediawiki.util.js +++ b/resources/src/mediawiki/mediawiki.util.js @@ -78,7 +78,6 @@ .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 9cada85c82..aa8c9c89c6 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's_Guide:_Using_tables +### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_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