Mercurial > hg
diff mercurial/url.py @ 36652:8381126bf43c
url: more bytes/unicodes fussing in url.py around auth handling
Once again, these methods are a little annoying to handle because they
can get unicodes or bytes depending on who's calling. I think we can
probably clean this up a TON once we can run something like pytype and
do typechecking of our Python, but until then this is going to be the
easy way out. This fixes test-http-bundle1.t.
Differential Revision: https://phab.mercurial-scm.org/D2599
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 03 Mar 2018 14:28:51 -0500 |
parents | 698fe0f6eb5c |
children | 02221d6fb041 |
line wrap: on
line diff
--- a/mercurial/url.py Sat Mar 03 14:24:21 2018 -0500 +++ b/mercurial/url.py Sat Mar 03 14:28:51 2018 -0500 @@ -67,7 +67,7 @@ user, passwd = auth.get('username'), auth.get('password') self.ui.debug("using auth.%s.* for authentication\n" % group) if not user or not passwd: - u = util.url(authuri) + u = util.url(pycompat.bytesurl(authuri)) u.query = None if not self.ui.interactive(): raise error.Abort(_('http authorization required for %s') % @@ -75,7 +75,7 @@ self.ui.write(_("http authorization required for %s\n") % util.hidepassword(bytes(u))) - self.ui.write(_("realm: %s\n") % realm) + self.ui.write(_("realm: %s\n") % pycompat.bytesurl(realm)) if user: self.ui.write(_("user: %s\n") % user) else: @@ -424,8 +424,8 @@ user, pw = self.passwd.find_user_password( realm, urllibcompat.getfullurl(req)) if pw is not None: - raw = "%s:%s" % (user, pw) - auth = 'Basic %s' % base64.b64encode(raw).strip() + raw = "%s:%s" % (pycompat.bytesurl(user), pycompat.bytesurl(pw)) + auth = r'Basic %s' % pycompat.strurl(base64.b64encode(raw).strip()) if req.get_header(self.auth_header, None) == auth: return None self.auth = auth