r14930 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14929‎ | r14930 | r14931 >
Date:09:20, 23 June 2006
Author:tstarling
Status:old
Tags:
Comment:
Fixed issues with careless use of Sanitizer::decodeCharReferences(), added a parser test case for one of them.
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -5444,6 +5444,16 @@
54455445 a
54465446 !! end
54475447
 5448+!! test
 5449+Handling of 
 in URLs
 5450+!! input
 5451+**irc://
a
 5452+!! result
 5453+<ul><li><ul><li><a href="irc://%0Aa" class="external free" title="irc://%0Aa" rel="nofollow">irc://%0Aa</a>
 5454+</li></ul>
 5455+</li></ul>
 5456+
 5457+!!end
54485458 #
54495459 #
54505460 #
Index: trunk/phase3/includes/Parser.php
@@ -1145,6 +1145,9 @@
11461146 # Normalize any HTML entities in input. They will be
11471147 # re-escaped by makeExternalLink().
11481148 $url = Sanitizer::decodeCharReferences( $url );
 1149+
 1150+ # Escape any control characters introduced by the above step
 1151+ $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url );
11491152
11501153 # Process the trail (i.e. everything after this link up until start of the next link),
11511154 # replacing any non-bracketed links
@@ -1228,6 +1231,9 @@
12291232 # Normalize any HTML entities in input. They will be
12301233 # re-escaped by makeExternalLink() or maybeMakeExternalImage()
12311234 $url = Sanitizer::decodeCharReferences( $url );
 1235+
 1236+ # Escape any control characters introduced by the above step
 1237+ $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url );
12321238
12331239 # Is this an external image?
12341240 $text = $this->maybeMakeExternalImage( $url );
@@ -1536,6 +1542,7 @@
15371543 $sortkey = $text;
15381544 }
15391545 $sortkey = Sanitizer::decodeCharReferences( $sortkey );
 1546+ $sortkey = str_replace( "\n", '', $sortkey );
15401547 $sortkey = $wgContLang->convertCategoryKey( $sortkey );
15411548 $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
15421549