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

Fix IPv6 hostname normalization #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 <lidel@lidel.org>
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.

None yet

1 participant