From: Wil Mahan Date: Mon, 11 Oct 2004 16:16:27 +0000 (+0000) Subject: Prevent double-escaping of '<' and '>' in external links; X-Git-Tag: 1.5.0alpha1~1593 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=6838bf3e06a0a29d08f6f6d362f0d2dbe7366aed;p=lhc%2Fweb%2Fwiklou.git Prevent double-escaping of '<' and '>' in external links; allow them in free external links again, at least until there is a consistent way of handling them. Convert some spaces to tabs from zhengzhu's last commit. --- diff --git a/includes/Parser.php b/includes/Parser.php index 4b79b83e25..82377a5143 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -38,7 +38,7 @@ define( 'UNIQ_PREFIX', 'NaodW29'); define( 'URL_PROTOCOLS', 'http|https|ftp|irc|gopher|news|mailto' ); define( 'HTTP_PROTOCOLS', 'http|https' ); # Everything except bracket, space, or control characters -define( 'EXT_LINK_URL_CLASS', '[^]<>\\x00-\\x20\\x7F]' ); +define( 'EXT_LINK_URL_CLASS', '[^]\\x00-\\x20\\x7F]' ); # Including space define( 'EXT_LINK_TEXT_CLASS', '[^\]\\x00-\\x1F\\x7F]' ); define( 'EXT_IMAGE_FNAME_CLASS', '[A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]' ); @@ -655,7 +655,7 @@ class Parser * @access private */ function internalParse( $text, $linestart, $args = array(), $isMain=true ) { - global $wgContLang; + global $wgContLang; $fname = 'Parser::internalParse'; wfProfileIn( $fname ); @@ -1026,8 +1026,11 @@ class Parser $url = substr( $url, 0, -$numSepChars ); } - # Replace & from obsolete syntax with & - $url = str_replace( '&', '&', $url ); + # Replace & from obsolete syntax with &; + # undo escaping of '<' and '>' by removeHTMLtags(), + # to prevent double-escaping. All HTML entities will + # be escaped by makeExternalLink() or maybeMakeImageLink() + $url = str_replace( array('&', '<', '>'), array('&', '<', '>'), $url ); # Is this an external image? $text = $this->maybeMakeImageLink( $url ); @@ -1291,7 +1294,7 @@ class Parser } } - $text = $wgContLang->convert($text); + $text = $wgContLang->convert($text); if( ( $nt->getPrefixedText() === $this->mTitle->getPrefixedText() ) && ( strpos( $link, '#' ) === FALSE ) ) {