diff options
author | Jonathon Jongsma <jonathon@quotidian.org> | 2009-09-15 14:54:02 -0500 |
---|---|---|
committer | Jonathon Jongsma <jonathon@quotidian.org> | 2009-09-15 14:54:02 -0500 |
commit | feb1c4788d7399dfafa7e7f82903d12ef9dbc998 (patch) | |
tree | 16a06f4d165b59f26ce9ab79355351746829be7a | |
parent | 9e026a19f7d3d7acc3ac8a82a9fc56512d80452c (diff) | |
download | git-bz-feb1c4788d7399dfafa7e7f82903d12ef9dbc998.tar.gz |
Fix exception when parsing an alias as a url
In BugHandle.parse(), we first try to parse the bug reference as a url and then
fall back to interpreting it as an alias from the config file. Unfortunately,
something like "gnome:123456" gets parsed as a url (with a scheme of 'gnome' and
a path of '123456', and no hostname). This resulted in us passing a None
hostname to tracker_get_auth_user(), which resulted in an uncaught exception.
From now on, only proceed with treating the bug reference as a url if the scheme
is parsed as 'http' or 'https'.
-rwxr-xr-x | git-bz | 45 |
1 files changed, 23 insertions, 22 deletions
@@ -399,28 +399,29 @@ class BugHandle: def parse(bug_reference): parseresult = urlparse.urlsplit (bug_reference) - user = parseresult.username - pwd = parseresult.password - # if the url did not specify http auth credentials in the form - # https://user:pwd@host.com, check to see whether the config file - # specifies any auth credentials for this host - if not user: - user = tracker_get_auth_user(parseresult.hostname) - if not pwd: - pwd = tracker_get_auth_password(parseresult.hostname) - - # strip off everything after the last '/', so '/bugzilla/show_bug.cgi' - # will simply become '/bugzilla' - path = parseresult.path[:parseresult.path.rfind('/')] - m = re.match("id=([^&]+)", parseresult.query) - - if m: - return BugHandle(host=parseresult.hostname, - path=path, - https=parseresult.scheme=="https", - id=m.group(1), - authuser=user, - authpwd=pwd) + if parseresult.scheme in ('http', 'https'): + user = parseresult.username + pwd = parseresult.password + # if the url did not specify http auth credentials in the form + # https://user:pwd@host.com, check to see whether the config file + # specifies any auth credentials for this host + if not user: + user = tracker_get_auth_user(parseresult.hostname) + if not pwd: + pwd = tracker_get_auth_password(parseresult.hostname) + + # strip off everything after the last '/', so '/bugzilla/show_bug.cgi' + # will simply become '/bugzilla' + path = parseresult.path[:parseresult.path.rfind('/')] + m = re.match("id=([^&]+)", parseresult.query) + + if m: + return BugHandle(host=parseresult.hostname, + path=path, + https=parseresult.scheme=="https", + id=m.group(1), + authuser=user, + authpwd=pwd) colon = bug_reference.find(":") if colon > 0: |