reject trailing bytes after IPv6 host literal in parse_url (#2536)

This commit is contained in:
metsw24-max authored and GitHub committed 2026-08-14 21:27:40 -04:00
1 parent 1e9d6f0b0b
commit 2d8e49dd9b
2 files changed
+26

No files matched your search

+9
View File
@@ -851,6 +851,15 @@ inline bool parse_url(const std::string &url, UrlComponents &uc) {
}
pos = close + 1;
// The IPv6 literal is the whole host, so ']' must be followed by a port,
// path, query or fragment delimiter (or the end of input). Otherwise the
// trailing bytes would be folded into the path while the connection
// still targets the bracketed address.
if (pos < url.size() && url[pos] != ':' && url[pos] != '/' &&
url[pos] != '?' && url[pos] != '#') {
return false;
}
} else {
auto end = url.find_first_of(":/?#", pos);
if (end == std::string::npos) { end = url.size(); }