Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
BBC RussianHomePhabricator
Log In
Maniphest T275074

Gallery does not allow lowercase "center" "left" or "right" as a caption for a gallery image
Open, MediumPublic

Description

This was initially reported as a false linter error on T266406 but further debugging revealed that Parsoid and Gallery are "eating" the words left, center or right (which make no sense anyway in the context of a Gallery image). Parsoid and Gallery provides a default halign value of none which when followed with a left, center or right word is parsed as an alignment, instead of passing through. These words get detected early on as an halign values and are consumed - so no longer available as a caption. They are also seen as a duplicate alignment parameter and flagged as a bogus parameter which the linter finds and reports erroneously.
The following wikitext demonstrates the issue:

<gallery>
File:Foobar.jpg|left
File:Foobar.jpg|notaleft
</gallery>

Event Timeline

For clarification, in case people are looking at this without context: Sometimes editors use "Center" as the caption for a gallery image, typically for an image showing the central area of buildings in a municipality. That caption is erroneously hidden by the MediaWiki software. It should be displayed.

Jonesey, this is a bug, and it will be fixed, not put off for years. It was
just more than a Linter bug, which is what I am focussing on, and after
debugging it, I determined that the problem occurs fairly early in the
parsing stages far removed from the Linter and is going to be tricky to
fix. I confirmed with my team mates that we will not deem this an annoying
quirk that we ignore, but fixing it was outside the scope of my current
tasks. I'll keep an eye on this task. Thanks for the additional insight as
to how editors might use Center more often than one might imagine.
Best,
Shannon

Arlolra renamed this task from Gallery does not allow "center" "left" or "right" as a caption for a gallery image to Gallery does not allow lowercase "center" "left" or "right" as a caption for a gallery image.Aug 24 2021, 3:14 PM

This bug may have been fixed at some point. I am seeing proper behavior, with no Linter errors reported, with the following code:

<gallery>
File:Foobar.jpg|left
File:Foobar.jpg|Left
File:Foobar.jpg|notleft
File:Foobar.jpg|center
File:Foobar.jpg|Center
File:Foobar.jpg|right
File:Foobar.jpg|Right
</gallery>

https://en.wikipedia.org/w/index.php?title=User:Jonesey95/sandbox2&oldid=1056627659

This bug may have been fixed at some point.

Nah, T266406 fixed some of it but it's still an issue

See the captions aren't rendered here, https://en.wikipedia.org/api/rest_v1/page/html/User:Jonesey95%2Fsandbox2/1056627659

And the lint is lost because it's considered a valid option {"ck":"left","ak":"left"} much like T214601,

> php bin/parse.php --restURL https://en.wikipedia.org/api/rest_v1/page/html/User:Jonesey95%2Fsandbox2/1056627659 --linting

<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-parsoid='{"dsr":[0,206,9,10]}' data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerybox" style="width: 155px;" data-parsoid="{}"><div class="thumb" style="width: 150px; height: 150px;" data-parsoid="{}"><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"120x120px"},{"ck":"left","ak":"left"}]}'><a href="./File:Foobar.jpg" data-parsoid="{}"><img resource="./File:Foobar.jpg" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" data-file-width="240" data-file-height="28" data-file-type="bitmap" height="14" width="120" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, //upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg 2x" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"14","width":"120"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></div><div class="gallerytext" data-parsoid="{}"></div></li>
...

This is still a problem, despite assurances in 2021 from @Sbailey (See above. This is not about Sbailey personally, but I worked in IT customer service for a long time and learned not to promise things that I was not sure I could deliver by myself).

The word "frame" renders fine but is not recognized as a valid caption by the Linter error-checker. Linter errors are reported. The same happens with "thumb" and "frameless".

https://en.wikipedia.org/w/index.php?title=User:Jonesey95/sandbox&oldid=1239819265

For some reason, "border" and "upright" do not cause Linter errors. I did not do exhaustive testing of all image options, but someone working on this bug should do so. That person could create a comprehensive set of test cases as part of addressing T274382, of which this bug is a tiny part.

One option that I know I have brought up in the past is to allow a "caption=" option to force the parser to recognize odd syntax (like "thumb" or "300px") as a caption. We have to do a similar thing with "1=" for templates when parameter values contain an "=" character.