mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #5414 from mondeja/5367
Raise InvalidUrl if host starts with '.' character.
This commit is contained in:
+1
-1
@@ -403,7 +403,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
host = self._get_idna_encoded_host(host)
|
||||
except UnicodeError:
|
||||
raise InvalidURL('URL has an invalid label.')
|
||||
elif host.startswith(u'*'):
|
||||
elif host.startswith((u'*', u'.')):
|
||||
raise InvalidURL('URL has an invalid label.')
|
||||
|
||||
# Carefully reconstruct the network location
|
||||
|
||||
@@ -81,6 +81,8 @@ class TestRequests:
|
||||
(InvalidSchema, 'localhost.localdomain:3128/'),
|
||||
(InvalidSchema, '10.122.1.1:3128/'),
|
||||
(InvalidURL, 'http://'),
|
||||
(InvalidURL, 'http://*example.com'),
|
||||
(InvalidURL, 'http://.example.com'),
|
||||
))
|
||||
def test_invalid_url(self, exception, url):
|
||||
with pytest.raises(exception):
|
||||
|
||||
Reference in New Issue
Block a user