Page MenuHomePhabricator

VE silently alters the HTML of an invalid wikitext sequence of a link with an image in the label, which dirty-diffs
Closed, ResolvedPublic1 Estimated Story Points

Description

(See https://office.wikimedia.org/w/index.php?diff=200728&oldid=200727)

  1. Use a wikitext editor to create a page with this link: [http://example.com Label [[File:Smiley.png|16px]]]
  2. Verify that the image in the link label is visible.
  3. Use the visual editor to edit the page. It is not necessary to touch the link itself.
  4. See that the image is not visible any longer.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I'm adding Parsoid to the tags so that the Parsing team can check this, too; feel free to remove the tag if it's not relevant.

I don't think [http://example.com Label [[File:Smiley.png|16px]]] is actually valid. With Tidy disabled, it generates the following HTML in PHP parser:

<a rel="nofollow" class="external text" href="http://example.org">Label <a href="/wiki/Plik:Smiley.png" class="image"><img alt="Smiley.png" src="/w/images/thumb/8/80/Smiley.png/16px-Smiley.png" width="16" height="16" srcset="/w/images/thumb/8/80/Smiley.png/24px-Smiley.png 1.5x, /w/images/thumb/8/80/Smiley.png/32px-Smiley.png 2x" data-file-width="152" data-file-height="151" /></a></a>

…with nested <a> tags, which is definitely not valid. Still, Parsoid doesn't have to actually break it when edited…

This is valid though: [http://example.org Label [[File:Smiley.png|16px|link=]]]

<a rel="nofollow" class="external text" href="http://example.org">Label <img alt="Smiley.png" src="/w/images/thumb/8/80/Smiley.png/16px-Smiley.png" width="16" height="16" srcset="/w/images/thumb/8/80/Smiley.png/24px-Smiley.png 1.5x, /w/images/thumb/8/80/Smiley.png/32px-Smiley.png 2x" data-file-width="152" data-file-height="151" /></a>

…and it doesn't seem to be affected by this issue (tested locally).

The links are invalid, but there should not have been any dirty diffs. My testing shows that this is a VE bug. VE seems to be clobbering the HTML.

I created the test page to try this out. I followed debugging instructions to dump HTML before/after edit in VE and I see the following diffs in the DOMs even though I only changed "bar" to "bare".

1,2c1,2
< <body id="mwAA" class="mw-content-ltr sitedir-ltr ltr mw-body mw-body-content mediawiki" dir="ltr" lang="en"><h2 id="mwAQ"> heading </h2>
< <p id="mwAg">foo: <a rel="mw:ExtLink" href="http://example.com" id="mwAw">Label <span typeof="mw:Image" id="mwBA"></span></a><a href="./File:Smiley.png" id="mwBQ"><img resource="./File:Smiley.png" src="//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/16px-Smiley.png" data-file-width="152" data-file-height="151" data-file-type="bitmap" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/32px-Smiley.png 2x, //upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/24px-Smiley.png 1.5x" id="mwBg" width="16" height="16"></a><span id="mwBw"> bar</span></p>
---
> <body id="mwAA" class="mw-content-ltr sitedir-ltr ltr mw-body mw-body-content mediawiki" dir="ltr" lang="en"><h2> heading </h2>
> <p id="mwAg">foo: <a href="http://example.com" rel="mw:ExtLink" id="mwAw">Label <span typeof="mw:Image" id="mwBA"><span><img></span></span></a><a href="%3AFile%3ASmiley.png" rel="mw:WikiLink" id="mwBQ"><img resource="./File:Smiley.png" src="//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/16px-Smiley.png" data-file-width="152" data-file-height="151" data-file-type="bitmap" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/32px-Smiley.png 2x, //upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/24px-Smiley.png 1.5x" id="mwBg" width="16" height="16"></a><span id="mwBw"> bar</span></p>
5c5
< <p id="mwCQ">bar</p></body>
---
> <p id="mwCQ">bare</p></body>

FYI: @Esanders @Jdforrester-WMF

Jdforrester-WMF renamed this task from Potentially valid but complex link was broken when a different part of the page was edited to VE silently alters the HTML of an invalid wikitext sequence of a link with an image in the label, which dirty-diffs.Dec 13 2016, 8:11 PM
Jdforrester-WMF triaged this task as Low priority.
Jdforrester-WMF set the point value for this task to 1.
Jdforrester-WMF moved this task from To Triage to TR0: Interrupt on the VisualEditor board.

Oh, I forgot about this completely, and just re-discovered it while fixing T267282.

Change 639633 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] ve.dm.MWExternalLinkAnnotation: Alienate malformed links

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

Change 639633 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] ve.dm.MWExternalLinkAnnotation: Alienate malformed links

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

matmarex claimed this task.