From: Max Semenik
Date: Mon, 13 Nov 2017 23:53:24 +0000 (-0800)
Subject: {{anchorencode:}} output should be always usable in links
X-Git-Tag: 1.31.0-rc.0~1438
X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/?a=commitdiff_plain;h=f9d4f53105e5883862860724f8399e2d2ab734a1;p=lhc%2Fweb%2Fwiklou.git
{{anchorencode:}} output should be always usable in links
Bug: T179544
Change-Id: If8098e3e839e8ba1cf27b6053017e818c556a733
---
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