[csswg-drafts] [css-syntax-3] New parsing algorithms do not handle `}` tokens correctly in style attributes (#11113)

AtkinsSJ has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-syntax-3] New parsing algorithms do not handle `}` tokens correctly in style attributes ==
[This WPT test](http://wpt.live/html/dom/elements/global-attributes/style-01.html) checks that `}` tokens inside a `style` attribute are ignored and skipped over. Specifically, these two cases from it fail when following the new parsing algorithms:

```html
<p style="};background:limegreen">This line should have a green background.
<p style="background:red;};background:limegreen">This line should have a green background.
```

The previous version of the spec [says](https://www.w3.org/TR/css-syntax-3/#ref-for-parse-a-list-of-declarations%E2%91%A0):
> "[Parse a list of declarations](https://www.w3.org/TR/css-syntax-3/#parse-a-list-of-declarations)" is for the contents of a style attribute, which parses text into the contents of a single style rule.

That then calls "consume a list of declarations", which when it sees a `}` token, discards it and the remaining tokens up until the next `;`, and then continues parsing the next declaration.

The current draft spec with the new parsing algorithms [says](https://drafts.csswg.org/css-syntax/#ref-for-parse-a-blocks-contents):
> "[Parse a block’s contents](https://drafts.csswg.org/css-syntax/#parse-a-blocks-contents)" is intended for parsing the contents of any block in CSS (including things like the style attribute), and APIs such as [the CSSStyleDeclaration cssText attribute](https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-csstext).

However, this now calls "consume a block’s contents" which when it sees a `}`, immediately exits out and returns the current list of declarations. This makes it fail the above test cases, because declarations after a `}` are completely ignored.

A Ladybird contributor has [proposed a change](https://github.com/LadybirdBrowser/ladybird/commit/1761b544850deb2313e697387aa67cb6b09fc831) which seems to restore the previous behaviour - basically by passing an `is style attribute` flag to "consume a block's contents" and using that to skip over declarations that contain a `}`.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11113 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 30 October 2024 16:18:55 UTC