From af0dafefa25d2af4c57b0348f839ab10e048a56f Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Tue, 15 Jun 2004 22:16:04 +0000 Subject: [PATCH] encode the section anchor part of links properly, #962955 --- includes/Skin.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index 2ee9bd3061..6cec9574cc 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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() ); -- 2.20.1