Page MenuHomePhabricator

Broken output for broken wiki/ext links containing html tags
Closed, ResolvedPublicBUG REPORT

Description

See this transcript:

$ echo "[[<div>[{{1x|foo}}]</div>]]" | php bin/parse.php
<p data-parsoid='{"dsr":[0,27,0,0]}'>[[&lt;div>[<span about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]],"dsr":[8,18,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]]]</p>

We are processing the div tags as text!

The above is a reduced test case for the busted output seen on https://nov.wikipedia.org/wiki/Template%3ACountry?useparsoid=1

Event Timeline

The template's issue is the result of a copy-paste error of Template:Navbar into Template:Transclude when these templates were brought to this wiki (from whence I do not know since the copy-paste occurred long after these have been converted on en.wp and several other places to use Lua). This edit pulling from en.wp's 2009 version of Template:Transclude fixes that issue (in both parsers).

As for the reduced case, that is broken in old parser too, which turns the divs into something useful but the intent seems clearly to be "make this a link":

image.png (87×126 px, 904 B)

I don't think there's something worth fixing here presently if the reduced case is somehow interesting. We go from one way of being broken to another. If anything, probably the rightest thing to do would be to dump a (likely-red) link of whatever the insides would turn into.

ssastry triaged this task as Low priority.EditedAug 22 2025, 4:40 PM

Ya, this isn't high priority by any means, but mostly that Parsoid is doing the wrong thing when it bails on a broken link. For now, we can accept this as GIGO maybe, and get to handling the bail-out better in the future.

ABreault-WMF subscribed.

With the patch from that task I get,

$ (T402586) echo "[[<div>[{{1x|foo}}]</div>]]" | php bin/parse.php
<p data-parsoid='{"dsr":[0,2,0,0]}'>[[</p><div data-parsoid='{"stx":"html","dsr":[2,25,5,6]}'>[<span about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]],"dsr":[8,18,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]</div><p data-parsoid='{"dsr":[25,27,0,0]}'>]]</p>

Change #1180960 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Retokenize wikilink target for non-wikilinks

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

Change #1180960 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Retokenize wikilink target for non-wikilinks

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

Change #1181757 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a18

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

Change #1181757 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.22.0-a18

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