From 418febc748f52e0e99e2d4dd603b806c64ec98cd Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 6 Sep 2010 19:05:41 -0400 Subject: Handle partial URLs Code to handle parsing a base-path out of the URL would get confused when given an URL without a path or an URL without a hostname. Catch those cases. --- git-bz | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/git-bz b/git-bz index 7f9dcf6..0a8f55b 100755 --- a/git-bz +++ b/git-bz @@ -405,6 +405,10 @@ class BugHandle: parseresult = urlparse.urlsplit (bug_reference) if parseresult.scheme in ('http', 'https'): + # Catch http://www.gnome.org and the oddball http:relative/path and http:/path + if len(parseresult.path) == 0 or parseresult.path[0] != '/' or parseresult.hostname is None: + raise BugParseError("Invalid bug reference '%s'" % bug_reference) + user = parseresult.username pwd = parseresult.password # if the url did not specify http auth credentials in the form @@ -417,12 +421,12 @@ class BugHandle: # strip off everything after the last '/', so '/bugzilla/show_bug.cgi' # will simply become '/bugzilla' - path = parseresult.path[:parseresult.path.rfind('/')] + base_path = parseresult.path[:parseresult.path.rfind('/')] m = re.match("id=([^&]+)", parseresult.query) if m: return BugHandle(host=parseresult.hostname, - path=path, + path=base_path, https=parseresult.scheme=="https", id=m.group(1), authuser=user, -- cgit v1.2.3