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

hackney_url:parse_url/1 raises an exception on a technically valid edge case #657

Open
adamkittelson opened this issue Sep 17, 2020 · 0 comments
Assignees

Comments

@adamkittelson
Copy link

It looks like hackney is just splitting on @ and winds up trying to treat part of the credentials as the port when a url containing @ in the credentials is parsed.

iex(3)> :hackney_url.parse_url("https://user@domain.com:p@assword@domain.com/some/path")
** (ArgumentError) argument error
    :erlang.list_to_integer('p@assword@domain.com')
    (hackney 1.16.0) /Users/adamkittelson/Code/paperboy/deps/hackney/src/hackney_url.erl:260: :hackney_url.parse_netloc/2

While this is admittedly a weird thing to do it is technically valid and parses correctly in other libraries. Elixir's URI module for example is able to parse it:

 URI.parse("https://user@domain.com:p@assword@domain.com/some/path")
%URI{
  authority: "user@domain.com:p@assword@domain.com",
  fragment: nil,
  host: "domain.com",
  path: "/some/path",
  port: 443,
  query: nil,
  scheme: "https",
  userinfo: "user@domain.com:p@assword"
}

For now I'm able to work around by parsing with URI and using the result to create the hackney_url record myself and passing that to hackney:request/5 but it would be great if hackney_url:parse_url/1 could be updated to follow the RFC.

The Elixir implementation for URI.parse/1 is here if that is useful: https://github.com/elixir-lang/elixir/blob/v1.10.0/lib/elixir/lib/uri.ex#L455

Thanks!
Adam

@benoitc benoitc self-assigned this Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants