Page MenuHomePhabricator

Parsoid's AttributeExpander doesn't stringify \n# correctly (which can appear in CSS styles)
Closed, ResolvedPublicBUG REPORT

Description

https://it.wikivoyage.org/wiki/Utente:Andyrom75
is rendered differently from
https://it.wikivoyage.org/w/index.php?title=Utente:Andyrom75&useparsoid=0

Chrome and Firefox (latest versions) provide the same result.

Event Timeline

Checking the rendered code, I've noticed that Parsoid eliminate the symbol "#" from the color definition.
In this way, the CSS rule become invalid.

This is the line WITHOUT Pasoid:
<div style="padding: 0.8em;border: 2px solid #777;background: #f8f8f8;color:black;text-align: left;margin: 0 0 1em;">

This is the line WITH Pasoid:
<div style="padding: 0.8em;border: 1px solid 777;background: f8f8f8;color:black;text-align: left;margin: 0 0 1em;" about="#mwt24" typeof="mw:ExpandedAttrs" id="mwIg" data-mw="{&quot;attribs&quot;:[[{&quot;txt&quot;:&quot;style&quot;,&quot;html&quot;:&quot;&lt;span about=\&quot;#mwt22\&quot; typeof=\&quot;mw:Transclusion\&quot; data-parsoid='{\&quot;pi\&quot;:[[{\&quot;k\&quot;:\&quot;color\&quot;,\&quot;named\&quot;:true}]],\&quot;dsr\&quot;:[1408,1431,null,null]}' data-mw='{\&quot;parts\&quot;:[{\&quot;template\&quot;:{\&quot;target\&quot;:{\&quot;wt\&quot;:\&quot;SectionText\&quot;,\&quot;href\&quot;:\&quot;./Template:SectionText\&quot;},\&quot;params\&quot;:{\&quot;color\&quot;:{\&quot;wt\&quot;:\&quot;4\&quot;}},\&quot;i\&quot;:0}}]}'&gt;style=\&quot;padding: 0.8em; border: 1px solid \n#777; background: \n#f8f8f8; color:black; text-align: left; margin: 0 0 1em; \&quot;&lt;/span&gt;&quot;},{&quot;html&quot;:&quot;&quot;}]]}">

Andyrom75 renamed this task from CSS border and background are broken with parsoid to Parsoid eliminate # in CSS rules.Nov 12 2025, 3:17 PM

Since in 6 months I got no reply, I've changed completely the templates to solve the local issue, but I leave open the ticket to track it.

ABreault-WMF subscribed.

It looks like template expansion to something like,

style="padding: 0.8em; border: 1px solid  
#4d64cf; background: 
#f3faff; color:black; text-align: left; margin: 0 0 1em;        "

which gets tokenized as a list item,

2-[peg]        | ---->    [{"type":"NlTk","dataParsoid":{"tsr":[42,43]}},{"type":"TagTk","name":"listItem","attribs":[{"k":"bullets","v":["#"],"srcOffsets":[43,43,43,44]}],"dataParsoid":{"tsr":[43,44]}},"4d64cf;"]

and then the attribute expander is dropping the hash when stringifying the result.

cscott renamed this task from Parsoid eliminate # in CSS rules to Parsoid's AttributeExpander doesn't stringify \n# correctly (which appears in CSS rules).Nov 20 2025, 3:27 PM
cscott renamed this task from Parsoid's AttributeExpander doesn't stringify \n# correctly (which appears in CSS rules) to Parsoid's AttributeExpander doesn't stringify \n# correctly (which can appear in CSS styles).

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

[mediawiki/services/parsoid@master] Restore bullets before retokenizing expanded attrs

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

Change #1225041 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Restore bullets before retokenizing expanded attrs

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

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

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.23.0-a12

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

Change #1228553 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.23.0-a12

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