From: Brion Vibber Date: Wed, 7 Jan 2009 00:00:45 +0000 (+0000) Subject: Reverting r45341 " Use Sanitizer::escapeId() in another place Reduce code duplication... X-Git-Tag: 1.31.0-rc.0~43541 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=4b6945cb8aea115a6fee889d419b17d874b16a2e;p=lhc%2Fweb%2Fwiklou.git Reverting r45341 " Use Sanitizer::escapeId() in another place Reduce code duplication some more, and fix section redirect after edit when $wgEnforceHtmlIds is off." This produces non-matching stuff like "#_Rock_on_dudes_" for == ''Rock on'' dudes ==. --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index e3ee5e74b2..7fcfb90a35 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4736,11 +4736,21 @@ class Parser * "== Header ==". */ public function guessSectionNameFromWikiText( $text ) { - global $wgEnforceHtmlIds; # Strip out wikitext links(they break the anchor) $text = $this->stripSectionName( $text ); - return '#' . Sanitizer::escapeId( $text, - $wgEnforceHtmlIds ? 'noninitial' : 'xml' ); + $headline = Sanitizer::decodeCharReferences( $text ); + # strip out HTML + $headline = StringUtils::delimiterReplace( '<', '>', '', $headline ); + $headline = trim( $headline ); + $sectionanchor = '#' . urlencode( str_replace( ' ', '_', $headline ) ); + $replacearray = array( + '%3A' => ':', + '%' => '.' + ); + return str_replace( + array_keys( $replacearray ), + array_values( $replacearray ), + $sectionanchor ); } /**