Skip to content
Myr

Raise InvalidURL if hosts starts with '.' as was reported at #5367.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Álvaro Mondéjar · committed by Nate Prewitt · parent 39d0fdd · Browse files · 2 files+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−1 removed

  • tests:+2 added−0 removed
  • other:+1 added−1 removed

2 files+3 added−1 removed

modified:requests/models.py+1 added-1 removed
401 unmodified lines
402 try:403 host = self._get_idna_encoded_host(host)404 except UnicodeError:405 raise InvalidURL('URL has an invalid label.')406 elif host.startswith(u'*'):406 elif host.startswith((u'*', u'.')):407 raise InvalidURL('URL has an invalid label.')408409 # Carefully reconstruct the network location410 netloc = auth or ''
563 unmodified lines
modified:tests/test_requests.py+2 added
79 unmodified lines
80 (InvalidSchema, 'localhost:3128'),81 (InvalidSchema, 'localhost.localdomain:3128/'),82 (InvalidSchema, '10.122.1.1:3128/'),83 (InvalidURL, 'http://'),84 (InvalidURL, 'http://*example.com'),85 (InvalidURL, 'http://.example.com'),86 ))87 def test_invalid_url(self, exception, url):88 with pytest.raises(exception):89 requests.get(url)
2500 unmodified lines