Don’t do surrogate replacement when preprocessing input stream #386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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#L16But 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.