@@ -166,6 +166,9 @@ enum url_cb_args {
166166// https://infra.spec.whatwg.org/#ascii-tab-or-newline
167167CHAR_TEST (8 , IsASCIITabOrNewline, (ch == ' \t ' || ch == ' \n ' || ch == ' \r ' ))
168168
169+ // https://infra.spec.whatwg.org/#c0-control
170+ CHAR_TEST (8 , IsC0Control, (ch >= ' \0 ' && ch <= ' \x1f ' ))
171+
169172// https://infra.spec.whatwg.org/#c0-control-or-space
170173CHAR_TEST (8 , IsC0ControlOrSpace, (ch >= ' \0 ' && ch <= ' ' ))
171174
@@ -191,12 +194,18 @@ T ASCIILowercase(T ch) {
191194}
192195
193196// 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')
200209
201210// https://url.spec.whatwg.org/#windows-drive-letter
202211TWO_CHAR_STRING_TEST(8 , IsWindowsDriveLetter,
@@ -485,7 +494,7 @@ void URLHost::ParseOpaqueHost(const char* input, size_t length) {
485494 output.reserve (length);
486495 for (size_t i = 0 ; i < length; i++) {
487496 const char ch = input[i];
488- if (ch != ' % ' && IsForbiddenHostCodePoint (ch)) {
497+ if (IsForbiddenHostCodePoint (ch)) {
489498 return ;
490499 } else {
491500 AppendOrEscape (&output, ch, C0_CONTROL_ENCODE_SET);
@@ -524,7 +533,7 @@ void URLHost::ParseHost(const char* input,
524533 // If any of the following characters are still present, we have to fail
525534 for (size_t n = 0 ; n < decoded.size (); n++) {
526535 const char ch = decoded[n];
527- if (IsForbiddenHostCodePoint (ch)) {
536+ if (IsForbiddenDomainCodePoint (ch)) {
528537 return ;
529538 }
530539 }
0 commit comments