From 4b6945cb8aea115a6fee889d419b17d874b16a2e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 7 Jan 2009 00:00:45 +0000 Subject: [PATCH] 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 ==. --- includes/parser/Parser.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 ); } /** -- 2.20.1