Merge "Sanitize underscores as core does, to not create broken links"

This commit is contained in:
jenkins-bot 2018-12-11 00:01:57 +00:00 committed by Gerrit Code Review
commit 9e981d28b6
2 changed files with 16 additions and 0 deletions

View file

@ -1080,6 +1080,7 @@ class Cite {
*/
private function normalizeKey( $key ) {
$key = Sanitizer::escapeIdForAttribute( $key );
$key = preg_replace( '/__+/', '_', $key );
$key = Sanitizer::safeEncodeAttribute( $key );
return $key;

View file

@ -271,6 +271,21 @@ Ref names containing a number
!! end
!! test
T184912: Consistent normalization of consecutive underscores
!! wikitext
<ref name="x__x">example</ref>
<references />
!! html
<p><sup id="cite_ref-x_x_1-0" class="reference"><a href="#cite_note-x_x-1">&#91;1&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-x_x-1"><span class="mw-cite-backlink"><a href="#cite_ref-x_x_1-0">↑</a></span> <span class="reference-text">example</span>
</li>
</ol></div>
!! end
!! test
Erroneous refs
!! wikitext