@@ -165,6 +165,9 @@ enum url_cb_args {
165
165
// https://infra.spec.whatwg.org/#ascii-tab-or-newline
166
166
CHAR_TEST (8 , IsASCIITabOrNewline, (ch == ' \t ' || ch == ' \n ' || ch == ' \r ' ))
167
167
168
+ // https://infra.spec.whatwg.org/#c0-control
169
+ CHAR_TEST (8 , IsC0Control, (ch >= ' \0 ' && ch <= ' \x1f ' ))
170
+
168
171
// https://infra.spec.whatwg.org/#c0-control-or-space
169
172
CHAR_TEST (8 , IsC0ControlOrSpace, (ch >= ' \0 ' && ch <= ' ' ))
170
173
@@ -192,10 +195,15 @@ T ASCIILowercase(T ch) {
192
195
// https://url.spec.whatwg.org/#forbidden-host-code-point
193
196
CHAR_TEST (8 , IsForbiddenHostCodePoint,
194
197
ch == ' \0 ' || ch == ' \t ' || ch == ' \n ' || ch == ' \r ' ||
195
- ch == ' ' || ch == ' #' || ch == ' %' || ch == ' /' ||
196
- ch == ' :' || ch == ' ?' || ch == ' @' || ch == ' [' ||
197
- ch == ' <' || ch == ' >' || ch == ' \\ ' || ch == ' ]' ||
198
- ch == ' ^' || ch == ' |' )
198
+ ch == ' ' || ch == ' #' || ch == ' /' || ch == ' :' ||
199
+ ch == ' ?' || ch == ' @' || ch == ' [' || ch == ' <' ||
200
+ ch == ' >' || ch == ' \\ ' || ch == ' ]' || ch == ' ^' ||
201
+ ch == ' |' )
202
+
203
+ // https://url.spec.whatwg.org/#forbidden-domain-code-point
204
+ CHAR_TEST (8 , IsForbiddenDomainCodePoint,
205
+ IsForbiddenHostCodePoint (ch) || IsC0Control(ch) ||
206
+ ch == '%' || ch == '\x7f')
199
207
200
208
// https://url.spec.whatwg.org/#windows-drive-letter
201
209
TWO_CHAR_STRING_TEST(8 , IsWindowsDriveLetter,
@@ -483,7 +491,7 @@ void URLHost::ParseOpaqueHost(const char* input, size_t length) {
483
491
output.reserve (length);
484
492
for (size_t i = 0 ; i < length; i++) {
485
493
const char ch = input[i];
486
- if (ch != ' % ' && IsForbiddenHostCodePoint (ch)) {
494
+ if (IsForbiddenHostCodePoint (ch)) {
487
495
return ;
488
496
} else {
489
497
AppendOrEscape (&output, ch, C0_CONTROL_ENCODE_SET);
@@ -522,7 +530,7 @@ void URLHost::ParseHost(const char* input,
522
530
// If any of the following characters are still present, we have to fail
523
531
for (size_t n = 0 ; n < decoded.size (); n++) {
524
532
const char ch = decoded[n];
525
- if (IsForbiddenHostCodePoint (ch)) {
533
+ if (IsForbiddenDomainCodePoint (ch)) {
526
534
return ;
527
535
}
528
536
}
0 commit comments