Skip to content

Don’t do surrogate replacement when preprocessing input stream #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sideshowbarker
Copy link
Member

@sideshowbarker sideshowbarker commented Nov 2, 2022

This PR fixes #383, as an alternative to #385.

This change drops the code for replacing surrogate code points from our implementation of “filter code points” from “Preprocessing the input stream” at https://drafts.csswg.org/css-syntax/#css-filter-code-points

I’ve also opened w3c/csswg-drafts#7997 with a patch for updating that part of the CSS Syntax spec to add a clarifying note.

w3c/csswg-drafts#3307 (comment) notes that the only way to produce a unpaired lone surrogate code point in CSS content is by directly assigning a DOMString with one in it via an OM operation; in other words, by manipulating a document using, e.g., document.styleSheets in JavaScript to insert a surrogate code point into the document. See the tests at https://github.com/web-platform-tests/wpt/blob/master/css/css-syntax/input-preprocessing.html#L16

But because the CSS validator doesn’t execute any JavaScript from a document, there’s no way for a document being checked by the CSS validator to contain any surrogate code points. Therefore, it’s unnecessary for our implementation to handle replacement of surrogate code points. In other words, our implementation can still conform to the spec requirements even if we don’t perform surrogate replacement.

Otherwise, if we keep the surrogate-replacement code, we don’t have any way to actually test it — because we can’t use document.styleSheets or any other JavaScript in the context of the CSS validator, and therefore have no way to write any test cases that would produce an unpaired lone surrogate in the content we need to test with.

Fixes #383

This change drops the code for replacing surrogate code points from our
implementation of “filter code points” from “Preprocessing the input
stream” at https://drafts.csswg.org/css-syntax/#css-filter-code-points

w3c/csswg-drafts#3307 (comment)
notes that the only way to produce a surrogate code point in CSS content
is by directly assigning a DOMString with one in it via an OM operation;
in other words, by manipulating a document using JavaScript to insert
a surrogate code point into the document.

But because the CSS validator doesn’t execute any JavaScript from a
document, there’s no way for a document being checked by the CSS
validator to contain any surrogate code points. Therefore, it’s
unnecessary for our implementation to handle replacement of surrogate
code points. In other words, our implementation can still conform to the
spec requirements even if we don’t perform surrogate replacement.
Copy link
Member

@ylafon ylafon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to check if it was possible to use code points to make this check, but it was clunky at best, so yes, the best is to remove it for now.

@ylafon ylafon merged commit 8ef8808 into main Nov 28, 2022
@sideshowbarker sideshowbarker deleted the sideshowbarker/surrogate-replacment-in-preprocessing-drop branch June 23, 2023 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse error with Unicode supplementary characters in “style” element in HTML document
2 participants