Fixed bug [ 1642634 ] Non-absolute URIs need their own exception
diff --git a/httplib2/__init__.py b/httplib2/__init__.py
index fd4c768..6ad8afe 100644
--- a/httplib2/__init__.py
+++ b/httplib2/__init__.py
@@ -82,6 +82,7 @@
class FailedToDecompressContent(HttpLib2Error): pass
class UnimplementedDigestAuthOptionError(HttpLib2Error): pass
class UnimplementedHmacDigestAuthOptionError(HttpLib2Error): pass
+class RelativeURIError(HttpLib2Error): pass
# Open Items:
# -----------
@@ -125,6 +126,8 @@
def urlnorm(uri):
(scheme, authority, path, query, fragment) = parse_uri(uri)
+ if not scheme or not authority:
+ raise RelativeURIError("Only absolute URIs are allowed. uri = %s" % uri)
authority = authority.lower()
scheme = scheme.lower()
if not path:
diff --git a/httplib2test.py b/httplib2test.py
index edda403..33e50d6 100755
--- a/httplib2test.py
+++ b/httplib2test.py
@@ -48,6 +48,11 @@
self.assertEqual( "http://example.org/mypath?a=b", httplib2.urlnorm("http://EXAMple.org/mypath?a=b")[-1])
self.assertEqual( "http://localhost:80/", httplib2.urlnorm("http://localhost:80")[-1])
self.assertEqual( httplib2.urlnorm("http://localhost:80/"), httplib2.urlnorm("HTTP://LOCALHOST:80"))
+ try:
+ httplib2.urlnorm("/")
+ self.fail("Non-absolute URIs should raise an exception")
+ except httplib2.RelativeURIError:
+ pass
class UrlSafenameTest(unittest.TestCase):
def test(self):