Page MenuHomePhabricator

Parsoid chokes on parser functions outputting special characters inside an attribute, replaces all quotes with "
Open, MediumPublic

Description

If you take the following wikitext:

<div style="background-color: {{#if:bad|#FF0000|#00FF00}};">
<div class="message">
Hello
</div>
</div>

and convert it to HTML, then back to wikitext again (either by switching from source mode to visual mode and back to source mode in VE, or using node bin/parse.js --wt2wt), then you will get the following wikitext back:

<div style="background-color: {{#if:bad|#FF0000|#00FF00}};&quot;>
<div class=&quot;message&quot;>
Hello
</div>
</div>

">
<div class="message">
Hello
</div>
</div>

Note &quot; appearing where " should appear in every place after the {{#if:}} parser function (even including the closing quote for the class attribute), and then the same HTML appearing again but with correct quotes.

This is a reduced test case I distilled out of a more complex failure; the key ingredient appears to be the fact that the {{#if:}} parser function inside the style attribute of the first div outputs a #, because if you change it to {{#if:bad|red|green}} it doesn't break.

This was originally reported to me by @Trizek-WMF , who found it while attempting to edit https://www.mediawiki.org/wiki/Topic:Uf0bj00x79a3fkxx in wikitext mode (Flow stores posts as HTML, so a wt2html transformation took place when the post was first saved, and an html2wt transformation takes place when you open it for editing as wikitext).

Event Timeline

LGoto triaged this task as Medium priority.Apr 17 2020, 4:19 PM
LGoto moved this task from Backlog to Bugs & Crashers on the Parsoid board.

These days, this roundtrips as,

<div style="background-color: {{#if:bad|#FF0000|#00FF00}};
">
<div class="message">
Hello
</div>
</div>

which isn't quite so bad