Skip to content
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

Handle '@' in username #457

Merged
merged 1 commit into from
Oct 27, 2020
Merged
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
3 changes: 2 additions & 1 deletion coursier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ def remove_auth_from_url(url):
host = url_parts[0]
if "@" not in host:
return url
userless_host = host[host.find("@") + 1:]
last_index=host.rfind("@", 0, None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI there are some split_url() tests that have weird urls that this probably won't work for. Not sure if those are real cases somebody has, or not.

https://github.com/bazelbuild/rules_jvm_external/blob/master/tests/unit/coursier_test.bzl#L208

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not realistic to have a host with @
My commit should fix those 2 cases:
username@whatever.com:password@host
username@whatever.com@itLikes@icanputanotheronehere@:password_with_@_why_not:host

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I don't think having that @ char in the path, in unencoded form, is even legal. But just FYI someone thought it was a valid use case.

userless_host=host[last_index + 1:]
new_url = "{}://{}".format(protocol, "/".join([userless_host] + url_parts[1:]))
return new_url

Expand Down