Use Sanitizer::escapeId() in another place
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 2 Jan 2009 20:30:53 +0000 (20:30 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 2 Jan 2009 20:30:53 +0000 (20:30 +0000)
Reduce code duplication some more, and fix section redirect after edit
when $wgEnforceHtmlIds is off.

includes/parser/Parser.php

index da32c00..a5adc7e 100644 (file)
@@ -4684,21 +4684,11 @@ class Parser
         * "== Header ==".
         */
        public function guessSectionNameFromWikiText( $text ) {
+               global $wgEnforceHtmlIds;
                # Strip out wikitext links(they break the anchor)
                $text = $this->stripSectionName( $text );
-               $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 );
+               return '#' . Sanitizer::escapeId( $text,
+                       $wgEnforceHtmlIds ? array() : 'xml' );
        }
 
        /**