summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2010-09-06 19:05:41 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2010-09-06 19:15:29 -0400
commit418febc748f52e0e99e2d4dd603b806c64ec98cd (patch)
tree49b84ec40151ba2dcb1bc7321ffead3fcbc7ba93
parentca9301d17cdfa96113d6a55a6a6b5f344a90fa20 (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-xgit-bz8
1 files 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,