The pipe | character in urls is now escaped. This solves a parser test
authorPlatonides <platonides@users.mediawiki.org>
Wed, 5 May 2010 22:37:59 +0000 (22:37 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Wed, 5 May 2010 22:37:59 +0000 (22:37 +0000)
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

RELEASE-NOTES
includes/Sanitizer.php
maintenance/parserTests.txt

index ab13082..991df1a 100644 (file)
@@ -153,6 +153,7 @@ in a negative namespace (which is invalid).
 * (Bug 23241) Remove License selector, because it is not used when uploading a
   new version.
 * (bug 23240) Add ID to namespace selector form on Special:Watchlist
+* The pipe | character in urls is now escaped.
 
 === API changes in 1.17 ===
 * (bug 22738) Allow filtering by action type on query=logevent
index 3d9317e..abc11f8 100644 (file)
@@ -1493,7 +1493,7 @@ class Sanitizer {
                $url = Sanitizer::decodeCharReferences( $url );
 
                # Escape any control characters introduced by the above step
-               $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url );
+               $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F\|]/e', "urlencode('\\0')", $url );
 
                # Validate hostname portion
                $matches = array();
index ade29b7..7656f45 100644 (file)
@@ -1514,7 +1514,7 @@ Piped link to URL
 !! input
 Piped link to URL: [[http://www.example.com|an example URL]]
 !! result
-<p>Piped link to URL: [<a href="http://www.example.com|an" class="external text" rel="nofollow">example URL</a>]
+<p>Piped link to URL: [<a href="http://www.example.com%7Can" class="external text" rel="nofollow">example URL</a>]
 </p>
 !! end
 
@@ -6649,12 +6649,10 @@ disabled
 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
 !! test
 Images with the "|" character in the comment
-!! options
-disabled
 !! input
 [[image:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
 !! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/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="/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>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/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="/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>
 
 !!end