Page MenuHomePhabricator

Linter link-in-link error not reported when link is inside nested reference
Open, MediumPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

Create a page with this code (templates are on en.WP):

Article text.{{efn|Footnote text.<ref>[https://example.com Footnote source with [[internal link]] in it.]</ref>}}

{{notelist}}

{{reflist}}

What happens?:
A Linter wikilink-in-extlink condition is created but not detected.

What should have happened instead?:
The page should appear at https://en.wikipedia.org/wiki/Special:LintErrors/wikilink-in-extlink and an error should be listed in Page Information.

Note that the same wikitext link outside of the nested reference generates an error properly: https://en.wikipedia.org/w/index.php?title=User:Jonesey95/sandbox&oldid=1146874185

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

The issue here doesn't seem to be nested references per se. It's enough for the ref to be in the first position of a transclusion. For example,

> echo "{{1x|a <ref>[https://example.com Footnote source with [[internal link]] in it.]</ref>}}" | php bin/parse.php --linting
{"type":"wikilink-in-extlink","dsr":[0,87,null,null],"templateInfo":{"name":"Template:1x"},"params":[]}
...

vs

> echo "{{1x|<ref>[https://example.com Footnote source with [[internal link]] in it.]</ref>}}" | php bin/parse.php --linting
...

When the <sup> gets marked with mw:Transclusion, the dataMw->body information that's set on the refDmw,
https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/src/Ext/Cite/References.php#L357-L359

gets dropped by,

$dmw = $isTplWrapper ? $tplDmw : $refDmw;
DOMDataUtils::setDataMw( $linkBack, $dmw );

and then the linter code doesn't know how to traverse to find the content,
https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/src/Ext/Cite/Ref.php#L58-L73

P45954 is enough to get this to work.

However, it's unclear if we should be adding data associated with the mw:Extension when the mw:Transclusion takes precedence. The larger issue is described in T214241.


The example in the task description expands to,

<ref group="lower-alpha">Footnote text.<ref>[https://example.com Footnote source with [[internal link]] in it.]</ref></ref>

and with the paste applied, produces,

> echo "{{efn|Footnote text.<ref>[https://example.com Footnote source with [[internal link]] in it.]</ref>}}" | php bin/parse.php --linting
{"type":"wikilink-in-extlink","dsr":[0,100,null,null],"templateInfo":{"name":"Template:Efn"},"params":[]}
...
Arlolra triaged this task as Medium priority.Mar 27 2023, 9:58 PM
Arlolra moved this task from Backlog to Parsoid on the MediaWiki-extensions-Linter board.
Arlolra added a project: Parsoid.
Arlolra moved this task from Needs Triage to Linting on the Parsoid board.