diff mercurial/url.py @ 45759:ff48eea4a926 stable

url: do not continue HTTP authentication with user=None (issue6425) I initially thought this is a py3-compat bug of passwordmgr._writedebug(), but actually returning (None, str) pair is wrong at all. HTTP authentication would continue with user="None" in that case. Since registering a password of user=None should also be wrong, this patch simply adds early return.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 23 Oct 2020 20:33:36 +0900
parents a50f33f1ff24
children 89a2afe31e82
line wrap: on
line diff
--- a/mercurial/url.py	Fri Oct 23 20:10:17 2020 +0900
+++ b/mercurial/url.py	Fri Oct 23 20:33:36 2020 +0900
@@ -96,6 +96,13 @@
             if not passwd:
                 passwd = self.ui.getpass()
 
+        # As of Python 3.8, the default implementation of
+        # AbstractBasicAuthHandler.retry_http_basic_auth() assumes the user
+        # is set if pw is not None. This means (None, str) is not a valid
+        # return type of find_user_password().
+        if user is None:
+            return None, None
+
         self.passwddb.add_password(realm, authuri, user, passwd)
         self._writedebug(user, passwd)
         return (pycompat.strurl(user), pycompat.strurl(passwd))