Skip to content
Snippets Groups Projects

Bug 40491: Don't auto-pick a v2 address when it's in Onion-Location header

+ 7
10
@@ -6836,30 +6836,27 @@ static bool IsValidOnionLocation(nsIURI* aDocumentURI,
}
// Current URI
bool isHttpish = false;
nsAutoCString host;
NS_ENSURE_SUCCESS(aDocumentURI->SchemeIs("https", &isHttpish), false);
if (!isHttpish) {
if (!aDocumentURI->SchemeIs("https")) {
return false;
}
NS_ENSURE_SUCCESS(aDocumentURI->GetAsciiHost(host), false);
if (StringEndsWith(host, ".onion"_ns)) {
// Already in the .onoin site
// Already in the .onion site
return false;
}
// Target URI
NS_ENSURE_SUCCESS(aOnionLocationURI->SchemeIs("http", &isHttpish), false);
if (!isHttpish) {
NS_ENSURE_SUCCESS(aOnionLocationURI->SchemeIs("https", &isHttpish), false);
if (!isHttpish) {
return false;
}
if (!aOnionLocationURI->SchemeIs("http") &&
!aOnionLocationURI->SchemeIs("https")) {
return false;
}
nsCOMPtr<nsIEffectiveTLDService> eTLDService =
do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
if (!eTLDService) {
NS_ENSURE_SUCCESS(aOnionLocationURI->GetAsciiHost(host), false);
// This should not happen, but in the unlikely case, still check if it is a
// .onion and in case allow it.
return StringEndsWith(host, ".onion"_ns);
}
NS_ENSURE_SUCCESS(eTLDService->GetBaseDomain(aOnionLocationURI, 0, host),
Loading