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

IPv6 addresses with brackets are not handled correctly. #34

Open
ahankinson opened this issue Sep 17, 2024 · 1 comment
Open

IPv6 addresses with brackets are not handled correctly. #34

ahankinson opened this issue Sep 17, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ahankinson
Copy link

The gleam/uri package handles parsing URIs with brackets correctly, since it uses the regex from rfc3986. As a consequence, it does not handle URIs that do not have brackets.

import gleam/io
import gleam/uri

pub fn main() {
  uri.parse("http://[123:456::789]:8000/com")
  |> io.debug
  // Ok(Uri(scheme: Some("http"), userinfo: None, host: Some("[123:456::789]"), port: Some(8000), path: "/com", query: None, fragment: None))


  uri.parse("http://123:456::789:8000/com")
  |> io.debug
  // Ok(Uri(scheme: Some("http"), userinfo: None, host: Some("123"), port: Some(456), path: "/com", query: None, fragment: None))
}

(The latter case should probably fail instead of producing an invalid host value, but that's another issue).

However, the httpc package is not currently configured to accept IPv6 addresses with brackets. Passing an IPv6 URI from uri.parse will produce value => {error,invalid_uri}

I'm wondering if the underlying erlang httpc module needs to have "ipv6_host_with_brackets" set to True?

https://www.erlang.org/doc/apps/inets/httpc.html#request/4

Here are some public IPv6 URIs to try:

http://[2606:2800:21f:cb07:6820:80da:af6b:8b2c] -> example.net, should give a 404 Not Found
http://[2a00:1450:400a:808::200e] -> google.com, should also give a 404

These should both succeed with httpc, and not error out with "invalid URI".

@lpil
Copy link
Member

lpil commented Sep 18, 2024

Thank you

@lpil lpil added bug Something isn't working help wanted Extra attention is needed labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants