@@ -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,
@@ -485,7 +494,7 @@ void URLHost::ParseOpaqueHost(const char* input, size_t length) {
485
494
output.reserve (length);
486
495
for (size_t i = 0 ; i < length; i++) {
487
496
const char ch = input[i];
488
- if (ch != ' % ' && IsForbiddenHostCodePoint (ch)) {
497
+ if (IsForbiddenHostCodePoint (ch)) {
489
498
return ;
490
499
} else {
491
500
AppendOrEscape (&output, ch, C0_CONTROL_ENCODE_SET);
@@ -524,7 +533,7 @@ void URLHost::ParseHost(const char* input,
524
533
// If any of the following characters are still present, we have to fail
525
534
for (size_t n = 0 ; n < decoded.size (); n++) {
526
535
const char ch = decoded[n];
527
- if (IsForbiddenHostCodePoint (ch)) {
536
+ if (IsForbiddenDomainCodePoint (ch)) {
528
537
return ;
529
538
}
530
539
}
0 commit comments