"In HTML4 mode, wikitext characters get escaped in the anchor name, e.g. <ref name="foo [[bar]]" /> generates wikitext like <sup id="cite_ref-foo_.5B.5Bbar.5D.5D_0-0" class="reference">[1]</sup>; note the brackets have changed to ".5B" and ".5D". In HTML5 mode, these characters aren't escaped, generating <sup id="cite_ref-foo_[[bar]]_0-0" class="reference">#cite_note-foo_[[bar-0|[1]]]</sup> instead, with brackets inside the attempted wikilink. Since brackets cannot actually appear inside a wikilink, boom. Anomie⚔"
Description
Details
- Reference
- bz27694
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | MaxSem | T75092 Anchors to section names for non-ASCII letters are encoded in the URL | |||
Resolved | matmarex | T172493 mw.util.escapeId should log deprecation warning | |||
Resolved | MaxSem | T152540 Migrate to HTML5 section ids | |||
Resolved | MaxSem | T175725 Deploy HTML5 sections to WMF production | |||
Resolved | MaxSem | T29694 Reference names can't contain square brackets in HTML5 fragment mode |
Event Timeline
ayg wrote:
This is actually due to $wgExperimentalHtmlIds, not $wgHtml5. It's just that the former does nothing unless the latter is true. This should be fixable in Cite by not encoding the ref name in the anchor name, just generate an arbitrary one.
(In reply to comment #0)
"In HTML4 mode, wikitext characters get escaped in the anchor name, e.g. <ref
name="foo [[bar]]" /> generates wikitext like <sup
id="cite_ref-foo_.5B.5Bbar.5D.5D_0-0"
class="reference">[1]</sup>; note the
brackets have changed to ".5B" and ".5D". In HTML5 mode, these characters
aren't escaped, generating <sup id="cite_ref-foo_[[bar]]_0-0"
class="reference">#cite_note-foo_[[bar-0|[1]]]</sup> instead, with brackets
inside the attempted wikilink. Since brackets cannot actually appear inside a
wikilink, boom. Anomie⚔"
Is this still an issue? According to https://noc.wikimedia.org/conf/InitialiseSettings.php.txt:
'wgHtml5' => array(
'default' => false,
'mediawikiwiki' => true,
'testwiki' => true,
'test2wiki' => true,
),
Using the following wikitext on test.wikipedia.org (testwiki) at https://test.wikipedia.org/wiki/Cite_using_HTML5:
Hello there.<ref name="foo [[bar]]">author</ref><ref name="foo [[bar]]" />
References
<references />
Generated HTML looks like this:
<p>Hello there.<sup id="cite_ref-foo_.5B.5Bbar.5D.5D_0-0" class="reference"><a href="#cite_note-foo_.5B.5Bbar.5D.5D-0">1</a><span class="reference_comma">,</span></sup><sup id="cite_ref-foo_.5B.5Bbar.5D.5D_0-1" class="reference"><a href="#cite_note-foo_.5B.5Bbar.5D.5D-0">1</a><span class="reference_comma">,</span></sup></p>
<h2> <span class="mw-headline" id="References">References</span></h2>
<ol class="references">
<li id="cite_note-foo_.5B.5Bbar.5D.5D-0"><span class="mw-cite-backlink">^ <span class="citerefmanylink"><a href="#cite_ref-foo_.5B.5Bbar.5D.5D_0-0"><sup><i><b>a</b></i></sup></a></span> <span class="citerefmanylink"><a href="#cite_ref-foo_.5B.5Bbar.5D.5D_0-1"><sup><i><b>b</b></i></sup></a></span></span> <span class="reference-text">author</span></li>
</ol>
This bug appears to be fixed. Can someone confirm?
(In reply to comment #2)
Using the following wikitext on test.wikipedia.org (testwiki) at
Does test.wikipedia.org have $wgExperimentalHtmlIds on or off?
ayg wrote:
Well, it defaults to false, because it's experimental:
If no one is actively developing it and fixing its bugs, it should probably remain false, or just be removed. I hope no one tried turning it on anywhere.
(In reply to comment #4)
I hope no one tried turning it on anywhere.
I guess someone did in February 2011.
ayg wrote:
Yes, I enabled it, and then re-disabled it when there were problems:
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=commitdiff;h=40a41100300c02abf95328e303ec4400de7a5fd9
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=commitdiff;h=e2ba564eb7e52b5863a7ae6de751070406709d5a
Change 390356 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Cite@master] Don't break when reference names contain []
Change 391135 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/core@master] Sanitizer::safeEncodeAttribute(): also encode ]
Change 390356 had a related patch set uploaded (by Legoktm; owner: MaxSem):
[mediawiki/extensions/Cite@master] Don't break when reference names contain []
Change 391135 merged by jenkins-bot:
[mediawiki/core@master] Sanitizer::safeEncodeAttribute(): also encode ]
Change 390356 merged by jenkins-bot:
[mediawiki/extensions/Cite@master] Don't break when reference names contain []