[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-91.2.0esr-11.0-1] Bug 40483: Temporarily redirect DW's v2 address to their new v3 address



commit 4928a95242dcd3e617cc1abc3231fab7c0015e0a
Author: Matthew Finkel <sysrqb@xxxxxxxxxxxxxx>
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

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits