encode the section anchor part of links properly, #962955
authorGabriel Wicke <gwicke@users.mediawiki.org>
Tue, 15 Jun 2004 22:16:04 +0000 (22:16 +0000)
committerGabriel Wicke <gwicke@users.mediawiki.org>
Tue, 15 Jun 2004 22:16:04 +0000 (22:16 +0000)
includes/Skin.php

index 2ee9bd3..6cec957 100644 (file)
@@ -1559,7 +1559,7 @@ class Skin {
        # Pass a title object, not a title string
        function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '')
        {
-               global $wgOut, $wgTitle;
+               global $wgOut, $wgTitle, $wgInputEncoding;
 
                $fname = 'Skin::makeKnownLinkObj';
                wfProfileIn( $fname );
@@ -1575,7 +1575,12 @@ class Skin {
                        $u = $nt->escapeLocalURL( $query );
                }
                if ( '' != $nt->getFragment() ) {
-                       $u .= '#' . htmlspecialchars( $nt->getFragment() );
+                       $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT, $wgInputEncoding ) );
+                       $replacearray = array(
+                               '%3A' => ':',
+                               '%' => '.'
+                       );
+                       $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
                }
                if ( '' == $text ) {
                        $text = htmlspecialchars( $nt->getPrefixedText() );