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

[tor-commits] [tor-browser] 24/73: Bug 1559205, 1611093, 1748828 - support moz-proxy in about:logins r=dimi a=RyanVM



This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.

commit 49eba737d88753cf9aaf4ffb187ad16b594b5c89
Author: Sergey Galich <sgalich@xxxxxxxxxxx>
AuthorDate: Mon Aug 22 14:49:32 2022 +0000

    Bug 1559205, 1611093, 1748828 - support moz-proxy in about:logins r=dimi a=RyanVM
    
    Uri.host throws when scheme is moz-proxy://
    This leads to a series of bugs on about:logins when creating or editing moz-proxy URLs.
    
    This patch is supposed to close bug 1559205, bug 1611093 and bug 1748828.
    
    Differential Revision: https://phabricator.services.mozilla.com/D154925
---
 toolkit/components/passwordmgr/LoginHelper.jsm               | 12 +++++++++++-
 .../passwordmgr/test/unit/test_getPasswordOrigin.js          |  4 ++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/toolkit/components/passwordmgr/LoginHelper.jsm b/toolkit/components/passwordmgr/LoginHelper.jsm
index 927fed2d46ca0..38d28e2cf7af1 100644
--- a/toolkit/components/passwordmgr/LoginHelper.jsm
+++ b/toolkit/components/passwordmgr/LoginHelper.jsm
@@ -649,12 +649,22 @@ this.LoginHelper = {
   getLoginOrigin(uriString, allowJS = false) {
     let realm = "";
     try {
+      const mozProxyRegex = /^moz-proxy:\/\//i;
+      const isMozProxy = !!uriString.match(mozProxyRegex);
+      if (isMozProxy) {
+        // Special handling because uri.displayHostPort throws on moz-proxy://
+        return (
+          "moz-proxy://" +
+          Services.io.newURI(uriString.replace(mozProxyRegex, "https://";))
+            .displayHostPort
+        );
+      }
+
       let uri = Services.io.newURI(uriString);
 
       if (allowJS && uri.scheme == "javascript") {
         return "javascript:";
       }
-      // TODO: Bug 1559205 - Add support for moz-proxy
 
       // Build this manually instead of using prePath to avoid including the userPass portion.
       realm = uri.scheme + "://" + uri.displayHostPort;
diff --git a/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js b/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js
index e0b8c11252c25..3aa72b62b05d7 100644
--- a/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js
+++ b/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js
@@ -23,6 +23,10 @@ const TESTCASES = [
   ["https://[::1]:443/foo";, "https://[::1]";],
   ["https://[::1]:8443/foo";, "https://[::1]:8443";],
   ["ftp://username:password@[::1]:2121/foo";, "ftp://[::1]:2121";],
+  [
+    "moz-proxy://username:password@123.456.789.123:12345/foo",
+    "moz-proxy://123.456.789.123:12345",
+  ],
 ];
 
 for (let [input, expected, allowJS] of TESTCASES) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits