|
@@ -196,7 +196,8 @@ template <typename CharT> bool is_uri_authority(std::basic_string_view<CharT> ur
|
|
|
|
|
|
|
|
// A URI Authority HOST section
|
|
// A URI Authority HOST section
|
|
|
// If the URI starts with '[', then it MUST BE an IPv6 or an "IPvFuture"
|
|
// If the URI starts with '[', then it MUST BE an IPv6 or an "IPvFuture"
|
|
|
- if (uri[0] == '[') {
|
|
|
|
|
|
|
+ bool const has_ipv6 = (uri[0] == '[');
|
|
|
|
|
+ if (has_ipv6) {
|
|
|
size_t pos = uri.find(']');
|
|
size_t pos = uri.find(']');
|
|
|
auto ip = uri.substr(1, pos - 1);
|
|
auto ip = uri.substr(1, pos - 1);
|
|
|
uri.remove_prefix(pos + 1);
|
|
uri.remove_prefix(pos + 1);
|
|
@@ -214,7 +215,9 @@ template <typename CharT> bool is_uri_authority(std::basic_string_view<CharT> ur
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Normal URI Authority HOST section is either an IPv4 or a HOSTNAME
|
|
// Normal URI Authority HOST section is either an IPv4 or a HOSTNAME
|
|
|
- return ipv4(to_u8(uri)) || hostname(uri);
|
|
|
|
|
|
|
+ // if we had an ipv6 part, we can permit an empty string (since hostname
|
|
|
|
|
+ // no longer permits them).
|
|
|
|
|
+ return (has_ipv6 && uri.empty()) || ipv4(to_u8(uri)) || hostname(uri);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Tests if a URI "Query Part" or "Fragment Part" is valid and remove the part
|
|
// Tests if a URI "Query Part" or "Fragment Part" is valid and remove the part
|