@@ -16,20 +16,23 @@ public int read()
16
16
int esc ;
17
17
int c = in .read ();
18
18
// https://www.w3.org/TR/css-syntax-3/#input-preprocessing
19
- if (c == 13 ) { // U+000D CARRIAGE RETURN (CR)
19
+ if (c == 0x000d ) { // U+000D CARRIAGE RETURN (CR)
20
20
mark (1 );
21
21
c = in .read ();
22
22
// eat any LF
23
- if (c != 10 ) { // U+000A LINE FEED (LF)
23
+ if (c != 0x000a ) { // U+000A LINE FEED (LF)
24
24
reset ();
25
25
}
26
- return 10 ; // U+000A LINE FEED (LF)
26
+ return 0x000a ; // U+000A LINE FEED (LF)
27
27
}
28
- if (c == 12 ) { //U+000C FORM FEED (FF)
29
- return 10 ;// U+000A LINE FEED (LF)
28
+ if (c == 0x000c ) { //U+000C FORM FEED (FF)
29
+ return 0x000a ;// U+000A LINE FEED (LF)
30
30
}
31
31
if (c == 0 ) { // U+0000 NULL
32
- return 65533 ; // U+FFFD REPLACEMENT CHARACTER
32
+ return 0xffd ; // U+FFFD REPLACEMENT CHARACTER
33
+ }
34
+ if (c >= 0xd800 && c <= 0xdfff ) { // surrogate
35
+ return 0xfffd ;
33
36
}
34
37
35
38
// now specific case of CSS unicode escape for ascii values [A-Za-z0-9].
@@ -94,16 +97,18 @@ public int read(char[] cbuf, int off, int len) throws IOException {
94
97
}
95
98
for (i = 0 , j = 0 ; i < l ; i ++) {
96
99
// pre-processing
97
- if (chars [i ] == 13 ) {
98
- chars [j ++] = 10 ;
100
+ if (chars [i ] == 0x000d ) {
101
+ chars [j ++] = 0x000a ;
99
102
// test for CRLF
100
- if (i + 1 < l && chars [i + 1 ] == 10 ) {
103
+ if (i + 1 < l && chars [i + 1 ] == 0x000a ) {
101
104
i ++;
102
105
}
103
- } else if (chars [i ] == 12 ) {
104
- chars [j ++] = 10 ;
106
+ } else if (chars [i ] == 0x000c ) {
107
+ chars [j ++] = 0x000a ;
105
108
} else if (chars [i ] == 0 ) {
106
- chars [j ++] = 65533 ;
109
+ chars [j ++] = 0xfffd ;
110
+ } else if (chars [i ] >= 0xd800 && chars [i ] <= 0xdfff ) {
111
+ chars [j ++] = 0xfffd ;
107
112
}
108
113
// escaping
109
114
0 commit comments