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