Bug: T179544
Change-Id: If8098e3e839e8ba1cf27b6053017e818c556a733
*/
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 ) {
<a href="/wiki/Foo" title="Foo">link <span title="title with [[double brackets]]">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="[foo]"></span><a href="#[foo]">#[foo]</a>
+</p>
+!! end