Fixed issues with careless use of Sanitizer::decodeCharReferences(), added a parser...
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 23 Jun 2006 09:20:44 +0000 (09:20 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 23 Jun 2006 09:20:44 +0000 (09:20 +0000)
includes/Parser.php
maintenance/parserTests.txt

index 37832a9..45ef8a1 100644 (file)
@@ -1145,6 +1145,9 @@ class Parser
                        # Normalize any HTML entities in input. They will be
                        # re-escaped by makeExternalLink().
                        $url = Sanitizer::decodeCharReferences( $url );
+                       
+                       # Escape any control characters introduced by the above step
+                       $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url );
 
                        # Process the trail (i.e. everything after this link up until start of the next link),
                        # replacing any non-bracketed links
@@ -1228,6 +1231,9 @@ class Parser
                                # Normalize any HTML entities in input. They will be
                                # re-escaped by makeExternalLink() or maybeMakeExternalImage()
                                $url = Sanitizer::decodeCharReferences( $url );
+                               
+                               # Escape any control characters introduced by the above step
+                               $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url );
 
                                # Is this an external image?
                                $text = $this->maybeMakeExternalImage( $url );
@@ -1536,6 +1542,7 @@ class Parser
                                                $sortkey = $text;
                                        }
                                        $sortkey = Sanitizer::decodeCharReferences( $sortkey );
+                                       $sortkey = str_replace( "\n", '', $sortkey );
                                        $sortkey = $wgContLang->convertCategoryKey( $sortkey );
                                        $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
 
index cdf188c..920f478 100644 (file)
@@ -5444,6 +5444,16 @@ section=1
                    a
 !! end
 
+!! test
+Handling of &#x0A; in URLs
+!! input
+**irc://&#x0A;a
+!! result
+<ul><li><ul><li><a href="irc://%0Aa" class="external free" title="irc://%0Aa" rel="nofollow">irc://%0Aa</a>
+</li></ul>
+</li></ul>
+
+!!end
 #
 #
 #