Page MenuHomePhabricator

Add linting rule for detecting presence of image wikitext in extlinks
Closed, ResolvedPublic

Description

See below:

[subbu@earth:~/work/wmf/parsoid] echo '[http://foo.bar/some.link [[Foo]] image]' | php bin/parse.php --linting > /dev/null
[{"type":"wikilink-in-extlink","dsr":[0,40,26,1],"params":[]}]
[subbu@earth:~/work/wmf/parsoid] echo '[http://foo.bar/some.link [[File:Foo.jpg|thumb]] image]' | php bin/parse.php --linting > /dev/null
[]

We need to add a new linting rule to detect the second scenario. That wikitext form is also broken since it causes the extlink to split into multiple fragments as with the wikilink-in-extlink scenario.

Event Timeline

ssastry triaged this task as Medium priority.Mar 24 2020, 4:11 AM
ssastry created this task.

See T267282#6641741 where we're saying this is valid in the case where |link=| suppresses the anchor element around the image.

There is already the 'wikilink-in-extlink' lint error, I guess it only considers "normal" links and not figures.

Change 659443 had a related patch set uploaded (by Sbailey; owner: Sbailey):
[mediawiki/services/parsoid@master] WIP Adding Linter case for figure link in extLink

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

In T248369#6641805, we're saying that |link=| is a valid use case and one where we wouldn't have a link-in-link scenario to lint anyways.

Along those lines, mw:Audio and mw:Video always suppress the link and emit a span, since you'd presumably want to play the media when clicking it rather than be taken off the page. So, they too wouldn't produce a link-in-link, however, these seem like cases where maybe you would want to lint since the purpose of suppressing the link is being defeated by the extlink.

See the spec and code for AddMediaInfo::handleLink
https://www.mediawiki.org/wiki/Specs/HTML/2.2.0#Audio/Video
https://github.com/wikimedia/parsoid/blob/master/src/Wt2Html/PP/Processors/AddMediaInfo.php#L540

The exception to all this is that media in general can have captions, which in turn can have links in them.

For example,

[http://google.com [[File:Test.jpg|link=|thumb|[[Testing]] 123]] 456]

Change 663052 had a related patch set uploaded (by Sbailey; owner: Sbailey):
[mediawiki/services/parsoid@master] WIP follow on patch to wikilink in extlink for video and audio

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

Change 659443 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Adding linter case for media in extlink

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

Change 663052 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Follow on patch to wikilink in extlink for video and audio content

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

Change 667711 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.13.0-a26

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

Change 667711 merged by jenkins-bot:
[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.13.0-a26

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