Page MenuHomePhabricator

Edge case difference processing templated styles in table cells
Open, NormalPublic

Description

Consider this wikitext

{|
|{{Grade II colour}}|X
|style="color:<nowiki>red</nowiki>"|Y
|style="color:<nowiki>
green</nowiki>"|Z
|}

<div {{Grade II colour}}>A</div>
<div style="color:<nowiki>red</nowiki>">B</div>
<div style="color:<nowiki>
green</nowiki>">C</div>

In all except the first table cell, the style attributes are properly handled. This is likely an edge case difference in attribute parsing in TableFixups DOM handler

Event Timeline

ssastry created this task.May 1 2019, 2:50 PM
Restricted Application added subscribers: Liuxinyu970226, jeblad, Aklapper. · View Herald TranscriptMay 1 2019, 2:50 PM
ssastry triaged this task as Normal priority.May 1 2019, 2:50 PM

Because of this bug, a number of cells on this page don't get a background colour.

cscott added a subscriber: Arlolra.May 1 2019, 3:14 PM
cscott added a subscriber: cscott.
cscott added a comment.EditedMay 1 2019, 3:25 PM

Current parsoid output for the test case wikitext above:

$ echo -n | bin/parse.js --pageName User:cscott/T222266
<!DOCTYPE html>
<html prefix="dc: http://purl.org/dc/terms/ mw: http://mediawiki.org/rdf/" about="http://en.wikipedia.org/wiki/Special:Redirect/revision/895030248"><head prefix="mwr: http://en.wikipedia.org/wiki/Special:Redirect/"><meta charset="utf-8"/><meta property="mw:pageNamespace" content="2"/><meta property="mw:pageId" content="60633826"/><link rel="dc:replaces" resource="mwr:revision/0"/><meta property="dc:modified" content="2019-05-01T15:20:40.000Z"/><meta property="mw:revisionSHA1" content="68d05a01c3a5c6743d96a854d9754428a3b4fcc1"/><meta property="mw:html:version" content="2.1.0"/><link rel="dc:isVersionOf" href="//en.wikipedia.org/wiki/User%3Acscott/T222266"/><title>User:Cscott/T222266</title><base href="//en.wikipedia.org/wiki/"/><link rel="stylesheet" href="//en.wikipedia.org/w/load.php?modules=mediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.skinning.content.parsoid%7Cmediawiki.skinning.interface%7Cskins.vector.styles%7Csite.styles%7Cext.cite.style%7Cext.cite.styles%7Cmediawiki.page.gallery.styles&amp;only=styles&amp;skin=vector"/><!--[if lt IE 9]><script src="//en.wikipedia.org/w/load.php?modules=html5shiv&amp;only=scripts&amp;skin=vector&amp;sync=1"></script><script>html5.addElements('figure-inline');</script><![endif]--><meta http-equiv="content-language" content="en"/><meta http-equiv="vary" content="Accept"/></head><body data-parsoid='{"dsr":[0,240,0,0]}' lang="en" class="mw-content-ltr sitedir-ltr ltr mw-body-content parsoid-body mediawiki mw-parser-output" dir="ltr"><table data-parsoid='{"dsr":[0,107,2,2]}'>
<tbody data-parsoid='{"dsr":[3,105,0,0]}'><tr data-parsoid='{"autoInsertedStart":true,"dsr":[3,104,0,0]}'><td about="#mwt18" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"{{Grade II colour}}":null},"sa":{"{{Grade II colour}}":""},"dsr":[3,25,21,0]}' data-mw='{"attribs":[[{"txt":"style=\"background-color: \"","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"pi\":[[]],\"dsr\":[4,23,null,null]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"Grade II colour\",\"href\":\"./Template:Grade_II_colour\"},\"params\":{},\"i\":0}}]}&apos;>style=\"background-color: &lt;/span>&lt;span typeof=\"mw:Nowiki\" about=\"#mwt1\" data-parsoid=\"{}\">\n#ACE1AF&lt;/span>&lt;span about=\"#mwt1\" data-parsoid=\"{}\">\"&lt;/span>"},{"html":""}]]}'>X</td>
<td style="color:red" about="#mwt4" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"style":"color:red"},"sa":{"style":"color:&lt;nowiki>red&lt;/nowiki>"},"dsr":[26,63,36,0]}' data-mw='{"attribs":[[{"txt":"style"},{"html":"color:&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[40,60,8,9]}&apos;>red&lt;/span>"}]]}'>Y</td>
<td style="color:
green" about="#mwt7" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"style":"color:\ngreen"},"sa":{"style":"color:&lt;nowiki>\ngreen&lt;/nowiki>"},"dsr":[64,104,39,0]}' data-mw='{"attribs":[[{"txt":"style"},{"html":"color:&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[78,101,8,9]}&apos;>\ngreen&lt;/span>"}]]}'>Z</td></tr>
</tbody></table>

<div style="background-color: 
#ACE1AF" about="#mwt20" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","dsr":[109,141,25,6]}' data-mw='{"attribs":[[{"txt":"style","html":"&lt;span about=\"#mwt8\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"pi\":[[]],\"dsr\":[114,133,null,null]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"Grade II colour\",\"href\":\"./Template:Grade_II_colour\"},\"params\":{},\"i\":0}}]}&apos;>style=\"background-color: &lt;/span>&lt;span typeof=\"mw:Nowiki\" about=\"#mwt8\" data-parsoid=\"{}\">\n#ACE1AF&lt;/span>&lt;span about=\"#mwt8\" data-parsoid=\"{}\">\"&lt;/span>"},{"html":""}]]}'>A</div>
<div style="color:red" about="#mwt11" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"color:red"},"sa":{"style":"color:&lt;nowiki>red&lt;/nowiki>"},"dsr":[142,189,40,6]}' data-mw='{"attribs":[[{"txt":"style"},{"html":"color:&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[160,180,8,9]}&apos;>red&lt;/span>"}]]}'>B</div>
<div style="color:
green" about="#mwt14" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"color:\ngreen"},"sa":{"style":"color:&lt;nowiki>\ngreen&lt;/nowiki>"},"dsr":[190,240,43,6]}' data-mw='{"attribs":[[{"txt":"style"},{"html":"color:&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[208,231,8,9]}&apos;>\ngreen&lt;/span>"}]]}'>C</div></body></html>

Dumping the calls to Sanitizer.normalizeCSS in Parsoid:

NORMALIZE CSS: { text: 'color:red' }
NORMALIZE CSS: { text: 'color:\ngreen' }
NORMALIZE CSS: { text: 'background-color: \n#ACE1AF' }
NORMALIZE CSS: { text: 'color:red' }
NORMALIZE CSS: { text: 'color:\ngreen' }

So the first background-color attribute isn't even making it to Parsoid these days, reaffirming @ssastry's theory about this being an issue in TableFixups. (Presumably at one point in the past it made it to normalizeCss since 898c9b9ec1443cd6510313e20059e1ec26f04e09 apparently made the background color appear. We've regressed at some point in the six (!) years since then. Confirmed that Ide0d1b6f503f17124aa9546dcb857adf1938a453 has no effect one way or the other.