You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RFC 3986 specifies that the userinfo subcomponent of a URI may contain the sub-delim tokens, so it is okay to include a literal plus sign (not percent-encoded) there, I believe (if not, please feel free to close this issue!).
model.url.URI seems to assume that these fields are always percent-encoded, leading to the replacement of + with a space in URI.get_username() and URI.get_password() (which are called internally by URI.to_string().
This is the root cause of pypa/pipenv#4271, which relies on this method for handling Git VCS URLs.
Expected behaviour
Parsing and formatting a URI containing a userinfo component where either the username or password contain a literal plus character (+) should not alter the content of these fields.
Suggested fix
If my understanding of the RFC as mentioned above is correct, URI._parse_auth should call quote_plus with the safe arg set to the sub-delim tokens from RFC 3986, preventing them from being escaped in the auth fields.
Note that the username and password fields are parsed correctly from the input but accessing them via get_username()/get_password() or formatting the URI as a string leads to the inadvertent replacement.
The text was updated successfully, but these errors were encountered:
AdrianoKF
changed the title
URI.get_username() and URI.get_password() fail for credentials containing literal plus sign
URI.get_username() and URI.get_password() replace literal plus signs with spaces
May 28, 2020
Description
RFC 3986 specifies that the userinfo subcomponent of a URI may contain the sub-delim tokens, so it is okay to include a literal plus sign (not percent-encoded) there, I believe (if not, please feel free to close this issue!).
model.url.URI
seems to assume that these fields are always percent-encoded, leading to the replacement of+
with a space inURI.get_username()
andURI.get_password()
(which are called internally byURI.to_string()
.This is the root cause of pypa/pipenv#4271, which relies on this method for handling Git VCS URLs.
Expected behaviour
Parsing and formatting a URI containing a userinfo component where either the username or password contain a literal plus character (
+
) should not alter the content of these fields.Suggested fix
If my understanding of the RFC as mentioned above is correct,
URI._parse_auth
should callquote_plus
with thesafe
arg set to thesub-delim
tokens from RFC 3986, preventing them from being escaped in the auth fields.Steps to reproduce
yields
Note that the username and password fields are parsed correctly from the input but accessing them via
get_username()
/get_password()
or formatting the URI as a string leads to the inadvertent replacement.The text was updated successfully, but these errors were encountered: