diff options
author | Andrey Petrov <shazow@gmail.com> | 2015-05-01 12:40:35 -0400 |
---|---|---|
committer | Andrey Petrov <shazow@gmail.com> | 2015-05-01 12:40:35 -0400 |
commit | 74073791a3429d9b9f375563954f57f2181599dc (patch) | |
tree | f002e7f3b87682296825e117d1e95c077fa9cd6f | |
parent | 4bddf26a6264607acb3d3dbf647ab12692325914 (diff) | |
parent | cedab2b040d19e8cbf88482252f4bd0c25a58488 (diff) | |
download | urllib3-74073791a3429d9b9f375563954f57f2181599dc.tar.gz |
Merge pull request #609 from t-8ch/url_implicit_leading_dash
don't allow path in urls which do not begin with /
-rw-r--r-- | test/test_util.py | 1 | ||||
-rw-r--r-- | urllib3/util/url.py | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/test/test_util.py b/test/test_util.py index ba26af5a..19ba57e3 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -97,6 +97,7 @@ class TestUtil(unittest.TestCase): parse_url_host_map = { 'http://google.com/mail': Url('http', host='google.com', path='/mail'), 'http://google.com/mail/': Url('http', host='google.com', path='/mail/'), + 'http://google.com/mail': Url('http', host='google.com', path='mail'), 'google.com/mail': Url(host='google.com', path='/mail'), 'http://google.com/': Url('http', host='google.com', path='/'), 'http://google.com': Url('http', host='google.com'), diff --git a/urllib3/util/url.py b/urllib3/util/url.py index b2ec834f..e58050cd 100644 --- a/urllib3/util/url.py +++ b/urllib3/util/url.py @@ -15,6 +15,8 @@ class Url(namedtuple('Url', url_attrs)): def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None, query=None, fragment=None): + if path and not path.startswith('/'): + path = '/' + path return super(Url, cls).__new__(cls, scheme, auth, host, port, path, query, fragment) |