jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/391141 )

Change subject: {{anchorencode:}} output should be always usable in links
......................................................................


{{anchorencode:}} output should be always usable in links

Bug: T179544

Change-Id: If8098e3e839e8ba1cf27b6053017e818c556a733
---
M includes/parser/CoreParserFunctions.php
M tests/parser/parserTests.txt
2 files changed, 13 insertions(+), 1 deletion(-)

Approvals:
  C. Scott Ananian: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/parser/CoreParserFunctions.php 
b/includes/parser/CoreParserFunctions.php
index bb0072c..07944d4 100644
--- a/includes/parser/CoreParserFunctions.php
+++ b/includes/parser/CoreParserFunctions.php
@@ -930,7 +930,8 @@
         */
        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 6e9f944..c3cea04 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -29729,3 +29729,14 @@
 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double 
brackets&#93;&#93;">span</span></a>
 </p>
 !! end
+
+!! test
+T179544: {{anchorencode:}} output should be always usable in links
+!! config
+wgFragmentMode=[ 'html5' ]
+!! wikitext
+<span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
+!! html/php
+<p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
+</p>
+!! end

-- 
To view, visit https://gerrit.wikimedia.org/r/391141
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If8098e3e839e8ba1cf27b6053017e818c556a733
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to