stream-http icon indicating copy to clipboard operation
stream-http copied to clipboard

Fix IPv6 hostname normalization

Open lidel opened this issue 6 years ago • 0 comments

The old check effectively merged the meaning of host and hostname, which was prone to errors:

  • in rare scenarios host could include : but be ipv4 with a custom port (eg. 127.0.0.1:8080) which would produce false-positives
  • ipv6 could already have square brackets([::1] – see the end of this comment), but normalization would run anyway and produced invalid URIs like http://[[::1]]:80

This changes ipv6 normalization to only run if actual hostname parameter is provided, includes : and does not start with [. Also, added missing tests for ipv6.

cc #18, https://github.com/ipfs-shipyard/ipfs-companion/issues/668

lidel avatar Jan 29 '19 13:01 lidel