r65969 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65968‎ | r65969 | r65970 >
Date:22:37, 5 May 2010
Author:platonides
Status:ok
Tags:
Comment:
The pipe | character in urls is now escaped. This solves a parser test
where a pipe in a url query inside an image caption confused the parser.

Windows file://c|/... urls may be affected. See
http://en.wikipedia.org/wiki/File_URI_scheme#Windows_2
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Sanitizer.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -1514,7 +1514,7 @@
15151515 !! input
15161516 Piped link to URL: [[http://www.example.com|an example URL]]
15171517 !! result
1518 -<p>Piped link to URL: [<a href="http://www.example.com|an" class="external text" rel="nofollow">example URL</a>]
 1518+<p>Piped link to URL: [<a href="http://www.example.com%7Can" class="external text" rel="nofollow">example URL</a>]
15191519 </p>
15201520 !! end
15211521
@@ -6649,12 +6649,10 @@
66506650 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
66516651 !! test
66526652 Images with the "|" character in the comment
6653 -!! options
6654 -disabled
66556653 !! input
66566654 [[image:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
66576655 !! result
6658 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/File:Foobar.jpg" class="image"><img alt="An external URL" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="https://www.mediawiki.org/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>An <a href="http://test/?param1=|left|&amp;param2=|x" class="external text" rel="nofollow">external</a> URL</div></div></div>
 6656+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="https://www.mediawiki.org/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>An <a href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx" class="external text" rel="nofollow">external</a> URL</div></div></div>
66596657
66606658 !!end
66616659
Index: trunk/phase3/includes/Sanitizer.php
@@ -1493,7 +1493,7 @@
14941494 $url = Sanitizer::decodeCharReferences( $url );
14951495
14961496 # Escape any control characters introduced by the above step
1497 - $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url );
 1497+ $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F\|]/e', "urlencode('\\0')", $url );
14981498
14991499 # Validate hostname portion
15001500 $matches = array();
Index: trunk/phase3/RELEASE-NOTES
@@ -153,6 +153,7 @@
154154 * (Bug 23241) Remove License selector, because it is not used when uploading a
155155 new version.
156156 * (bug 23240) Add ID to namespace selector form on Special:Watchlist
 157+* The pipe | character in urls is now escaped.
157158
158159 === API changes in 1.17 ===
159160 * (bug 22738) Allow filtering by action type on query=logevent

Status & tagging log