Page MenuHomePhabricator

Parsoid does not convert links with a template in the fragment in them correctly
Open, MediumPublic

Description

echo "<a href=\"./Talk:Steve_Jobs/Archive_1#{{editsemiprotected}}Jobs_named_CEO_of_the_Decade\" rel=\"mw:WikiLink\">Talk:Steve Jobs/Archive 1#{{editsemiprotected}}Jobs_named_CEO_of_the_Decade</a>" | cargo run --example convert
[[Talk:Steve Jobs/Archive 1#{{editsemiprotected}}Jobs_named_CEO_of_the_Decade]]

However this wikitext is not the same as the HTML, as the template will be expanded. Expected wikitext:

[[Talk:Steve Jobs/Archive 1#&#123;&#123;editsemiprotected&#125;&#125;Jobs_named_CEO_of_the_Decade]]

I am generating the <a> tag myself so I can link to https://en.wikipedia.org/wiki/Talk:Steve_Jobs/Archive_1#{{editsemiprotected}}Jobs_named_CEO_of_the_Decade

Event Timeline

If the link text is different from the link itself, then it will be properly escaped, but the link itself will still be wrong:

echo "<a href=\"./Talk:Steve_Jobs/Archive_1#{{editsemiprotected}}Jobs_named_CEO_of_the_Decade\" rel=\"mw:WikiLink\">Talk:Steve Jobs/Archive 1#{{aeditsemiprotected}}Jobs_named_CEO_of_the_Decade</a>" | cargo run --example convert
[[Talk:Steve Jobs/Archive 1#{{editsemiprotected}}Jobs named CEO of the Decade|Talk:Steve Jobs/Archive 1#<nowiki>{{aeditsemiprotected}}</nowiki>Jobs_named_CEO_of_the_Decade]]

...and unsurprisingly Parsoid is smarter than me. [[Talk:Steve Jobs/Archive 1#<nowiki>{{editsemiprotected}}</nowiki>Jobs_named_CEO_of_the_Decade]], which is what I was expecting Parsoid to produce isn't actually a valid link. So I'm not really sure what output Parsoid should be producing,

Maybe something like [[Talk:Steve Jobs/Archive 1#&lbrace;&lbrace;editsemiprotected&rbrace;&rbrace;Jobs_named_CEO_of_the_Decade]]?

Maybe something like [[Talk:Steve Jobs/Archive 1#&lbrace;&lbrace;editsemiprotected&rbrace;&rbrace;Jobs_named_CEO_of_the_Decade]]?

>>> echo wfEscapeWikitext('{{editsemiprotected}}');
&#123;&#123;editsemiprotected&#125;&#125;

So I'd expect [[Talk:Steve Jobs/Archive 1#&#123;&#123;editsemiprotected&#125;&#125;Jobs_named_CEO_of_the_Decade]]

Arlolra triaged this task as Medium priority.Nov 29 2021, 7:02 PM
Arlolra moved this task from Needs Triage to Bugs & Crashers on the Parsoid board.

Change 742577 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] [WIP] Wikitext escape link fragments

https://gerrit.wikimedia.org/r/742577

Change 742577 abandoned by Arlolra:

[mediawiki/services/parsoid@master] [WIP] Wikitext escape link fragments

Reason:

Can restore when picking it up again

https://gerrit.wikimedia.org/r/742577