Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,15 @@ def prepare_url(self, url, params):
host = self._get_idna_encoded_host(host)
except UnicodeError:
raise InvalidURL("URL has an invalid label.")
elif host.startswith(("*", ".")):
elif host.startswith("."):
raise InvalidURL("URL has an invalid label.")

# Normalize FQDN trailing dot (RFC 1035). Browsers and curl strip the
# trailing dot from fully qualified domain names to prevent redirect loops
# when servers redirect from the FQDN form to the bare domain.
if host.endswith("."):
host = host[:-1]

# Carefully reconstruct the network location
netloc = auth or ""
if netloc:
Expand Down