@@ -165,6 +165,9 @@ enum url_cb_args {
165165// https://infra.spec.whatwg.org/#ascii-tab-or-newline
166166CHAR_TEST (8 , IsASCIITabOrNewline, (ch == ' \t ' || ch == ' \n ' || ch == ' \r ' ))
167167
168+ // https://infra.spec.whatwg.org/#c0-control
169+ CHAR_TEST (8 , IsC0Control, (ch >= ' \0 ' && ch <= ' \x1f ' ))
170+
168171// https://infra.spec.whatwg.org/#c0-control-or-space
169172CHAR_TEST (8 , IsC0ControlOrSpace, (ch >= ' \0 ' && ch <= ' ' ))
170173
@@ -192,10 +195,15 @@ T ASCIILowercase(T ch) {
192195// https://url.spec.whatwg.org/#forbidden-host-code-point
193196CHAR_TEST (8 , IsForbiddenHostCodePoint,
194197 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')
199207
200208// https://url.spec.whatwg.org/#windows-drive-letter
201209TWO_CHAR_STRING_TEST(8 , IsWindowsDriveLetter,
@@ -483,7 +491,7 @@ void URLHost::ParseOpaqueHost(const char* input, size_t length) {
483491 output.reserve (length);
484492 for (size_t i = 0 ; i < length; i++) {
485493 const char ch = input[i];
486- if (ch != ' % ' && IsForbiddenHostCodePoint (ch)) {
494+ if (IsForbiddenHostCodePoint (ch)) {
487495 return ;
488496 } else {
489497 AppendOrEscape (&output, ch, C0_CONTROL_ENCODE_SET);
@@ -522,7 +530,7 @@ void URLHost::ParseHost(const char* input,
522530 // If any of the following characters are still present, we have to fail
523531 for (size_t n = 0 ; n < decoded.size (); n++) {
524532 const char ch = decoded[n];
525- if (IsForbiddenHostCodePoint (ch)) {
533+ if (IsForbiddenDomainCodePoint (ch)) {
526534 return ;
527535 }
528536 }
0 commit comments