diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2010-09-06 19:05:41 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2010-09-06 19:15:29 -0400 |
commit | 418febc748f52e0e99e2d4dd603b806c64ec98cd (patch) | |
tree | 49b84ec40151ba2dcb1bc7321ffead3fcbc7ba93 | |
parent | ca9301d17cdfa96113d6a55a6a6b5f344a90fa20 (diff) |
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.
-rwxr-xr-x | git-bz | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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, |