by evgpbfhnr · 5mo ago · 0 comments
(rationale being that whatwg said no: https://github.com/whatwg/url/issues/392 ; firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=700999 )
The "solution" is to use a proxy such as https://github.com/twisteroidambassador/prettysocks/tree/ipv... which incidentally encode the % as a `s` and handle special URLs like this http://fe80--1ff-fe23-4567-890as3.ipv6-literal.net for you through the socks dns resolution feature... I've never found anything else that works recently -_-
--- a/netwerk/base/nsURLHelper.cpp
+++ b/netwerk/base/nsURLHelper.cpp
@@ -928,3 +928,3 @@ bool net_IsValidIPv4Addr(const nsACString& aAddr) {
bool net_IsValidIPv6Addr(const nsACString& aAddr) {
- return mozilla::net::rust_net_is_valid_ipv6_addr(&aAddr);
+ return true;
}
Or if you actually wanted to do some validation, pass the address to getaddrinfo(): bool net_IsValidIPv6Addr(const nsACString& aAddr) {
struct addrinfo *res, hints = {.ai_flags = AI_NUMERICHOST};
int err = getaddrinfo(aAddr.get(), nullptr, &hints, &res);
if (err) return false;
bool isValid = res[0].ai_family != AF_INET;
freeaddrinfo(res);
return isValid;
}
This way it's valid if your OS considers it a valid address.