Skip to content

Commit 62d8c80

Browse files
Don’t do surrogate replacement when preprocessing input stream
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.
1 parent ebabe74 commit 62d8c80

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

org/w3c/css/util/UnescapeFilterReader.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public int read()
3131
if (c == 0) { // U+0000 NULL
3232
return 0xfffd; // U+FFFD REPLACEMENT CHARACTER
3333
}
34-
if (c >= 0xd800 && c <= 0xdfff) { // surrogate
35-
return 0xfffd;
36-
}
3734

3835
// now specific case of CSS unicode escape for ascii values [A-Za-z0-9].
3936
if (c != '\\') {
@@ -108,8 +105,6 @@ public int read(char[] cbuf, int off, int len) throws IOException {
108105
chars[j++] = 0x000a;
109106
} else if (chars[i] == 0) {
110107
chars[j++] = 0xfffd;
111-
} else if (chars[i] >= 0xd800 && chars[i] <= 0xdfff) {
112-
chars[j++] = 0xfffd;
113108
}
114109
// escaping
115110

0 commit comments

Comments
 (0)