Skip to content

Conversation

lidel
Copy link

@lidel lidel commented Jan 29, 2019

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, ipfs/ipfs-companion#668

The old check looked at both `host` and `hostname`, which was prone to
errors for multiple reasons:
- `host` could include `:` but be ipv4
- ipv6 could already have square brackets, which produced invalid URIs like
  `http://[[::1]]:80`

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

License: MIT
Signed-off-by: Marcin Rataj <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant