From f9d4f53105e5883862860724f8399e2d2ab734a1 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Mon, 13 Nov 2017 15:53:24 -0800 Subject: [PATCH] {{anchorencode:}} output should be always usable in links Bug: T179544 Change-Id: If8098e3e839e8ba1cf27b6053017e818c556a733 --- includes/parser/CoreParserFunctions.php | 3 ++- tests/parser/parserTests.txt | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index bb0072c037..07944d4648 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -930,7 +930,8 @@ class CoreParserFunctions { */ public static function anchorencode( $parser, $text ) { $text = $parser->killMarkers( $text ); - return (string)substr( $parser->guessSectionNameFromWikiText( $text ), 1 ); + $section = (string)substr( $parser->guessSectionNameFromWikiText( $text ), 1 ); + return Sanitizer::safeEncodeAttribute( $section ); } public static function special( $parser, $text ) { diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 6e9f9447d3..c3cea0457c 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -29729,3 +29729,14 @@ T72875: Test for brackets in attributes of elements in internal link texts link span

!! end + +!! test +T179544: {{anchorencode:}} output should be always usable in links +!! config +wgFragmentMode=[ 'html5' ] +!! wikitext +[[#{{anchorencode:[foo]}}]] +!! html/php +

#[foo] +

+!! end -- 2.20.1