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

Bug: T179544

Change-Id: If8098e3e839e8ba1cf27b6053017e818c556a733
This commit is contained in:
Max Semenik 2017-11-13 15:53:24 -08:00 committed by C. Scott Ananian
parent 962529515d
commit f9d4f53105
2 changed files with 13 additions and 1 deletions

View file

@ -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 ) {

View file

@ -29729,3 +29729,14 @@ T72875: Test for brackets in attributes of elements in internal link texts
<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