bpo-30458: Use InvalidURL instead of ValueError. (GH-13044)

Use http.client.InvalidURL instead of ValueError as the new error case's exception.
This commit is contained in:
Gregory P. Smith 2019-05-01 16:39:21 -04:00 committed by GitHub
parent e1d5dd645d
commit b7378d7728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -1091,7 +1091,7 @@ class HTTPConnection:
url = '/'
# Prevent CVE-2019-9740.
if match := _contains_disallowed_url_pchar_re.search(url):
raise ValueError(f"URL can't contain control characters. {url!r} "
raise InvalidURL(f"URL can't contain control characters. {url!r} "
f"(found at least {match.group()!r})")
request = '%s %s %s' % (method, url, self._http_vsn_str)