commit 7ab6b90cb0971d1d88eaa4d30496cd36c0f2ac92 Author: Matthew Finkel sysrqb@torproject.org Date: Mon Oct 4 22:45:56 2021 +0000
Bug 40483: Temporarily redirect DW's v2 address to their new v3 address --- docshell/base/nsDocShell.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c86fed307be6..080754c938b8 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5990,6 +5990,7 @@ already_AddRefed<nsIURI> nsDocShell::AttemptURIFixup( bool aNotifyKeywordSearchLoading, nsIInputStream** aNewPostData) { if (aStatus != NS_ERROR_UNKNOWN_HOST && aStatus != NS_ERROR_NET_RESET && aStatus != NS_ERROR_CONNECTION_REFUSED && + aStatus != NS_ERROR_TOR_ONION_SVC_BAD_ADDRESS && aStatus != mozilla::psm::GetXPCOMFromNSSError(SSL_ERROR_BAD_CERT_DOMAIN)) { return nullptr; @@ -6137,6 +6138,18 @@ already_AddRefed<nsIURI> nsDocShell::AttemptURIFixup( } } } + } else if (aStatus == NS_ERROR_TOR_ONION_SVC_BAD_ADDRESS) { + // Bug 40483: Temporarily redirect DW's v2 address to their new v3 address + constexpr auto kV2DW = "dwnewsvdyyiamwnp.onion"_ns; + constexpr auto kV3DW = "dwnewsgngmhlplxy6o2twtfgjnrnjxbegbwqx6wnotdhkzt562tszfid.onion"_ns; + nsAutoCString host; + newURI = nullptr; + Unused << url->GetHost(host); + if (StringEndsWith(host, kV2DW)) { + auto& subdomains = Substring(host, 0, host.Length() - kV2DW.Length()); + Unused << NS_MutateURI(url).SetHost(subdomains + kV3DW).Finalize( + getter_AddRefs(newURI)); + } } else if (aStatus == NS_ERROR_CONNECTION_REFUSED && Preferences::GetBool("browser.fixup.fallback-to-https", false)) { // Try HTTPS, since http didn't work