-
-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve the case of username and password in URL.build #920
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Preserve the case of username and password in URL.build when extracted from host. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,3 +257,14 @@ def test_build_with_none_query_string(): | |
def test_build_with_none_fragment(): | ||
with pytest.raises(TypeError): | ||
URL.build(scheme="http", host="example.com", fragment=None) | ||
|
||
|
||
def test_build_with_case_sensitive_user_and_password(): | ||
url = URL.build(scheme='httPS', host='usER:passWORD@hostNAME', path='/paTH') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, why this information would ever be a part of the host? I don't think the API should allow for it at all... |
||
assert url.user == "usER" | ||
assert url.password == "passWORD" | ||
|
||
|
||
def test_build_with_case_sensitive_user(): | ||
url = URL.build(scheme='httPS', host='usER@hostNAME', path='/paTH') | ||
assert url.user == "usER" | ||
Comment on lines
+262
to
+270
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like these are the same test. So I'd recommend using Also, I don't believe that scheme needs to be case-insensitive. Do you have any RFC reference that clarify this corner case? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,12 @@ def build( | |
elif not user and not password and not host and not port: | ||
netloc = "" | ||
else: | ||
if "@" in host and not user and not password: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a weird place to extract this data from.. Could you add more detail regarding the problem you're trying to address? |
||
user_pass, host = host.split("@", 1) | ||
if ":" in user_pass: | ||
user, password = user_pass.split(":", 1) | ||
else: | ||
user = user_pass | ||
netloc = cls._make_netloc( | ||
user, password, host, port, encode=not encoded, encode_host=not encoded | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use the past tense and RST markup here.