Use LIBXML_NOEMPTYTAG to avoid creating self-closing <a> tag

Browsers just treat the self-closed <a> tag as only the open
tag, so anything after the map would become linked.

tidy normally cleans this up, but other wikis without it, or
those using RemexHtml would see this issue.

Fix suggested by Phabricator user Porplemontage

Bug: T136855
Change-Id: I3b00e1a9cbb096afebe37614a79548f64d561e3b
This commit is contained in:
Karsten Hoffmeyer 2017-10-11 14:05:46 +02:00 committed by Kunal Mehta
parent 85568e99a9
commit 2ba1d20fcd
2 changed files with 2 additions and 2 deletions

View file

@ -353,7 +353,7 @@ class ImageMap {
// Output the result
// We use saveXML() not saveHTML() because then we get XHTML-compliant output.
// The disadvantage is that we have to strip out the DTD
$output = preg_replace( '/<\?xml[^?]*\?>/', '', $domDoc->saveXML() );
$output = preg_replace( '/<\?xml[^?]*\?>/', '', $domDoc->saveXML( null, LIBXML_NOEMPTYTAG ) );
// Register links
foreach ( $links as $title ) {

View file

@ -5,6 +5,6 @@ dummy test
Image:Foobar.jpg
</imagemap>
!! result
<div class="noresize" style="height: 220px; width: 1941px; "><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220"/><div style="margin-left: 1921px; margin-top: -20px; text-align: left;"><a href="/wiki/File:Foobar.jpg" title="About this image"><img alt="About this image" src="/extensions/ImageMap/desc-20.png?15600" style="border: none;"/></a></div></div>
<div class="noresize" style="height: 220px; width: 1941px; "><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220"></img><div style="margin-left: 1921px; margin-top: -20px; text-align: left;"><a href="/wiki/File:Foobar.jpg" title="About this image"><img alt="About this image" src="/extensions/ImageMap/desc-20.png?15600" style="border: none;"></img></a></div></div>
!! end