Page MenuHomePhabricator

regression: Imagemap fails with "Error: Image is invalid or non-existent." if caption has a <br>
Closed, ResolvedPublic

Description

I imported a page with an imagemap (Architectural Modules of MediaWiki) from a wiki running 1.24.1 to mw.org running early 1.26, and instead of the imagemap got a red

Error: Image is invalid or non-existent.

After fiddling with it (see bug case at https://www.mediawiki.org/wiki/User:SPage_%28WMF%29/imagemap_bug ) I determined the <br> in the image description line caused the problem:

<imagemap>
Image:RequestModules.svg|thumb|center|600px|Caption<br><small>More details</small>
</imagemap>

Workaround: remove the <br> and it works.

is this a parser change?

Event Timeline

Spage raised the priority of this task from to Needs Triage.
Spage updated the task description. (Show Details)
Spage added projects: ImageMap, Regression.
Spage moved this task to Backlog on the ImageMap board.
Spage subscribed.
Spage set Security to None.

The problem is at: line 97 of rEIMA/includes/ImageMap.php

  • It reads as: loadXML( $imageHTML )
  • That means: This part of the file parameter is supposed to contain XML.
  • Now it is fed with a <br> tag. XML is expecting a closing </br> tag (which is actually nonsense in HTML). Since there is no closing tag found loadXML() issues an error message and the extension beaks.

It works with XHTML <br /> void element.

  • This has a side effect: loadXML() is turning <br /> into <br></br>. Later the second one then is turned into <br> again by Wiki post-parsing Remex HTML cleanup.
  • Use a pair <div> </div> which produces a new line by block element.
matmarex subscribed.

I ran into this yesterday while editing and it peeved me very much. Luckily it's much easier to fix today than it was in 2015.

Change 850313 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/ImageMap@master] Use Parsoid's HTML5-compliant helpers for HTML transformations

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

Change 850313 merged by jenkins-bot:

[mediawiki/extensions/ImageMap@master] Use Parsoid's HTML5-compliant helpers for HTML transformations

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