Page MenuHomePhabricator

Better handling of entities & nowikis seen in templated attributes
Closed, ResolvedPublic0 Estimated Story Points

Description

When Parsoid encounters nowikis and entities, it wraps them in a span. However when these entities and nowikis show up in attributes of HTML elements, they pretty much break the HTML element.

Couple examples are:
https://phabricator.wikimedia.org/T69850#736117 (entity inside a <td> attribute)

and

https://fr.wikipedia.org/w/index.php?title=Mod%C3%A8le:Infobox/Ligne_mixte&action=edit (nowiki inside a <th> attribute)

This breaks the rendering (and editability of pages that use such wikitext).

Event Timeline

ssastry raised the priority of this task from to Medium.
ssastry updated the task description. (Show Details)
ssastry added a project: Parsoid.
ssastry subscribed.

Since the immediate issues have been fixed by fixing templates, I am moving this out of the VE Q3 column for now.

Parsoid output on the following snippet should show the problem and also provide a test case:

{|
|{{echo|1=style="background:#f9f9f9;" {{!}} X}}
|{{echo|1=style="background:&#35;f9f9f9;" {{!}} Y}}
|}

<div {{echo|1=style="background:#f9f9f9;"}}>foo</div>
<div {{echo|1=style="background:&#35;f9f9f9;"}}>foo</div>

Parsoid output:

[subbu@earth tests] node parse --normalize < /tmp/wt

<table>
<tbody>
<tr>
<td style="background:#f9f9f9;">X</td>
<td>style="background:#<span>f9f9f9;" | Y</span></td>
</tr>
</tbody>
</table>
<div style="background:#f9f9f9;">foo</div>
<div style=" background:">foo</div>

So, this only seems a problem when entities/nowikis are combined with templates when it comes to attributes. So, could be something to fix in the Attribute Expander.

{|
|style="background:&#35;f9f9f9;"| Y
|}

<div style="background:&#35;f9f9f9;">foo</div>

Parsoid output on that (which looks just fine):

<table data-parsoid='{"dsr":[0,41,2,2]}'>
<tbody data-parsoid='{"dsr":[3,39,0,0]}'><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true,"dsr":[3,38,0,0]}'><td style="background:#f9f9f9;" data-parsoid='{"a":{"style":"background:#f9f9f9;"},"sa":{"style":"background:&amp;#35;f9f9f9;"},"autoInsertedEnd":true,"dsr":[3,38,33,0]}'> Y</td></tr>
</tbody></table>

<div style="background:#f9f9f9;" data-parsoid='{"stx":"html","a":{"style":"background:#f9f9f9;"},"sa":{"style":"background:&amp;#35;f9f9f9;"},"dsr":[43,89,37,6]}'>foo</div>
ssastry renamed this task from Better handling of entities & nowikis seen in html element attributes to Better handling of entities & nowikis seen in templated attributes.Mar 9 2015, 10:13 PM
ssastry set Security to None.

Change 195491 had a related patch set uploaded (by Subramanya Sastry):
WIP: T90028: Deal with entities/nowikis in templated attrs.

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