Skip to content

Commit c106784

Browse files
committed
Fix check limit (was one char past z... which is { leading to improper unescape of it) and fixed escape aprsing after one non-hexadecimal char was read.
Thanks to @dd8 for the report.
1 parent ad2337f commit c106784

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

org/w3c/css/util/UnescapeFilterReader.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public int read()
5353
val = (val << 4) + (esc - 87);
5454
} else if (esc == 10 || esc == 9 || esc == 32) { // CSS whitespace.
5555
// U+000A LINE FEED, U+0009 CHARACTER TABULATION, or U+0020 SPACE.
56-
if ((val > 96 && val < 124) || (val > 64 && val < 91)) {
56+
if ((val > 96 && val < 123) || (val > 64 && val < 91)) {
5757
return val;
5858
}
5959
} else {
60-
if ((val > 96 && val < 124) || (val > 64 && val < 91)) {
60+
if ((val > 96 && val < 123) || (val > 64 && val < 91)) {
6161
//we must unread 1
6262
in.reset();
6363
i++;
@@ -71,7 +71,7 @@ public int read()
7171
}
7272
}
7373
// we read up to 6 char test value first
74-
if ((val <= 96 || val >= 124) && (val <= 64 || val >= 91)) {
74+
if ((val <= 96 || val >= 123) && (val <= 64 || val >= 91)) {
7575
in.reset();
7676
return c;
7777
}
@@ -129,7 +129,7 @@ public int read(char[] cbuf, int off, int len) throws IOException {
129129
val = (val << 4) + (cki - 87);
130130
} else if (cki == 10 || cki == 9 || cki == 32) { // CSS whitespace.
131131
// U+000A LINE FEED, U+0009 CHARACTER TABULATION, or U+0020 SPACE.
132-
if ((val > 96 && val < 124) || (val > 64 && val < 91)) {
132+
if ((val > 96 && val < 123) || (val > 64 && val < 91)) {
133133
chars[j++] = (char) val;
134134
escaped = true;
135135
i += k;
@@ -140,26 +140,27 @@ public int read(char[] cbuf, int off, int len) throws IOException {
140140
break;
141141
} else {
142142
if (val == 0) {
143-
if ((cki > 96 && cki < 124) || (cki > 64 && cki < 91)) {
143+
if ((cki > 96 && cki < 123) || (cki > 64 && cki < 91)) {
144144
// so we found a regular char, just remove the escaping
145145
++i;
146146
ignoreEscape = true;
147147
break;
148148
}
149149
}
150-
if ((val > 96 && val < 124) || (val > 64 && val < 91)) {
150+
if ((val > 96 && val < 123) || (val > 64 && val < 91)) {
151151
chars[j++] = (char) val;
152152
escaped = true;
153153
i += k - 1;
154154
break;
155155
} else {
156156
ignoreEscape = true;
157+
break;
157158
}
158159
}
159160
}
160161
if (!ignoreEscape) {
161162
if (k == 7 && !escaped) {
162-
if ((val > 96 && val < 124) || (val > 64 && val < 91)) {
163+
if ((val > 96 && val < 123) || (val > 64 && val < 91)) {
163164
chars[j++] = (char) val;
164165
escaped = true;
165166
i += k - 1;

0 commit comments

Comments
 (0)