Page MenuHomePhabricator

<gallery> handling of link parameter a bit odd
Open, MediumPublic

Description

Gallery handling of link parameter is a bit odd (presumably due to recursiveTagParsing and trimming things before splitting up by '|' instead of after).

Example:

<gallery>
Foo.jpg|link=http://somewhere.com|caption
</gallery>

Expected behaviour: Link to http://somewhere.com
Actual behaviour: Link to http://somewhere.com%2Ccaption

<gallery>
Foo.jpg|link=http://somewhere.com |caption
</gallery>

Expected behaviour: link to http://somewhere.com
Actual behaviour: it treats it as an internal link - http://mywiki.com/w/index.php/http://somewhere.com

I suppose if we changed this we would have to be careful over breaking back-compat(?). In particular the whole recursiveTagParse thing probably means someone is using {{!}} to split up components.

Details

Reference
bz47646

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:36 AM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz47646.
bzimport added a subscriber: Unknown Object (MLST).

I'm going to add to this bug other oddities with the link= parameter in galleries (I'm not sure if it should be split, but seemed related):

  • Internal links with an anchor: The anchor is stripped from the link:

    File:Foo.jpg|link=Article#Anchor Is rendered with a link to Article

Test case: https://www.mediawiki.org/w/index.php?oldid=849650

Bumping importance & priority to normal, since for issues in comment 1 there are no workarounds (workaround for comment 0 is to leave the link= parameter at the end). Maybe it would make sense to split it, but I'm not sure if it's something specific to galleries or more general as Bawolff suggests

Also, it would make sense to expect that "link=" removes the link from the image just as it does in regular image links. However, the link persists.

I can file a separate bug about this, if that helps.

Case #1 is still buggy: (however, it works correctly in Parsoid)

<gallery>
Foo.jpg|link=http://somewhere.com|caption
</gallery>

Expected behaviour: Link to http://somewhere.com
Actual behaviour: Link to http://somewhere.com%2Ccaption

Cases #2, #3 and #4 work correctly today in both parsers:

<gallery>
Foo.jpg|link=http://somewhere.com |caption
</gallery>

Expected behaviour: link to http://somewhere.com
Actual behaviour: it treats it as an internal link - http://mywiki.com/w/index.php/http://somewhere.com>

I'm going to add to this bug other oddities with the link= parameter in galleries (I'm not sure if it should be split, but seemed related):

  • External links with ampersands get the ampersands double-HTML-escaped: the link has the & converted to &amp; when you open it, the HTML source is "&amp;amp;"

    File:Foo.jpg|link=http://example.com/?param1=1&param2=2 Is rendered with a link to http://example.com/?param1=1&amp;param2=2
  • Internal links with an anchor: The anchor is stripped from the link:

    File:Foo.jpg|link=Article#Anchor Is rendered with a link to Article

Test case: https://www.mediawiki.org/w/index.php?oldid=849650