It was using Parser::guessSectionNameFromWikiText, which expects
a string of wikitext (e.g. "== Foo ==") and extracts the heading
text, and from that it generates an ID, and from that it
generates an anchor link.
The extraction and anchor link are wrong and caused the output
to be <h2 id="#Foo"> instead of <h2 id="Foo">.
Follows up I702f2f13.
Bug: 44989
Change-Id: I81f67ae1ac86ed709c69f1bced970b2cbb5138db
* @return string The HTML.
*/
protected function makeHeader( $header ) {
- global $wgParser;
- $spanAttribs = array( 'class' => 'mw-headline', 'id' => $wgParser->guessSectionNameFromWikiText( $header ) );
+ $spanAttribs = array( 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) );
return Html::rawElement( 'h2', array(), Html::element( 'span', $spanAttribs, $header ) );
}