Page MenuHomePhabricator

Linktrail should not bleed out of templates
Closed, ResolvedPublic

Description

I created https://en.wikipedia.org/wiki/User:Mattflaschen-WMF/FlowMention to demo this. The markup of FlowMention is:

@[[User:{{{1|Example}}}|{{{2|{{{1|Example}}}}}}]]<nowiki />

The markup of the transclusion is:

{{User:Mattflaschen-WMF/FlowMention|Admin}}foo

Core renders it as:

<p>@<a href="/w/index.php?title=User:Admin&amp;action=edit&amp;redlink=1" class="new" title="User:Admin (page does not exist)">Admin</a>foo</p>

Parsoid renders it as:

<p data-parsoid="{&quot;dsr&quot;:[0,46,0,0]}"><span about="#mwt1" typeof="mw:Transclusion" data-parsoid="{&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]],&quot;dsr&quot;:[0,43,null,null]}" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;User:Mattflaschen-WMF/FlowMention&quot;,&quot;href&quot;:&quot;./User:Mattflaschen-WMF/FlowMention&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;Admin&quot;}},&quot;i&quot;:0}},&quot;foo&quot;]}">@</span><a rel="mw:WikiLink" href="./User:Admin" title="User:Admin" about="#mwt1" data-parsoid="{&quot;stx&quot;:&quot;piped&quot;,&quot;a&quot;:{&quot;href&quot;:&quot;./User:Admin&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;User:Admin&quot;},&quot;tail&quot;:&quot;foo&quot;}">Adminfoo</a></p>

Event Timeline

Mattflaschen-WMF renamed this task from Parsoid does not handle templates ending in <nowiki /> the same way are core to Parsoid does not handle templates ending in <nowiki /> the same way as core.
Mattflaschen-WMF claimed this task.
Mattflaschen-WMF raised the priority of this task from to Needs Triage.
Mattflaschen-WMF updated the task description. (Show Details)
Mattflaschen-WMF added a project: Parsoid.
Mattflaschen-WMF set Security to None.
Catrope renamed this task from Parsoid does not handle templates ending in <nowiki /> the same way as core to Linktrail should not bleed out of templates.Aug 29 2015, 12:55 AM

A more self-contained example:

$ echo "{{echo|[[foo]]}}bar" | node tests/parse.js --normalize

<p><a href="Foo" title="Foo">foobar</a></p>

As Matt points out, adding <nowiki /> doesn't change the behavior:

$ echo "{{echo|[[foo]]<nowiki />}}bar" | node tests/parse.js --normalize

<p><a href="Foo" title="Foo">foobar</a></p>

Adding a zero-width non-breaking space (evil, I know) works, but Parsoid converts it to a normal space:

$ echo "{{echo|[[foo]]&#xfeff;}}bar" | node tests/parse.js --normalize

<p><a href="Foo" title="Foo">foo</a> bar</p>

(confirmed with hexedit that the space after </a> really is 0x20)

A more self-contained example:

$ echo "{{echo|[[foo]]}}bar" | node tests/parse.js --normalize

<p><a href="Foo" title="Foo">foobar</a></p>

This one turns out to be the same in PHP.

PHP:

<a href="/wiki/Foo" title="" class="mw-redirect">foobar</a>

Parsoid:

<a rel="mw:WikiLink" href="./Foo" title="Foo" about="#mwt1" typeof="mw:Transclusion" data-parsoid="{&quot;stx&quot;:&quot;simple&quot;,&quot;a&quot;:{&quot;href&quot;:&quot;./Foo&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;foo&quot;},&quot;dsr&quot;:[0,19,null,3],&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]],&quot;tail&quot;:&quot;bar&quot;}" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;[[foo]]&quot;}},&quot;i&quot;:0}},&quot;bar&quot;]}">foobar</a>
ssastry triaged this task as Medium priority.Sep 9 2015, 2:51 PM

I didn't mean to assign this to myself. I think it was automatic since I created a subtask.

Change 607098 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Fix incorrect handling of tpl-span-wrapped text in HandleLinkNeighbors

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

Change 607098 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Fix incorrect handling of tpl-span-wrapped text in HandleLinkNeighbors

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

Change 616335 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/vendor@master] Bump parsoid to 0.13.0-a2

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

Change 616335 merged by jenkins-bot:
[mediawiki/vendor@master] Bump parsoid to 0.13.0-a2

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