-
Notifications
You must be signed in to change notification settings - Fork 57
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 parsing / printing of IPv6 addresses in URIs #169
fix parsing / printing of IPv6 addresses in URIs #169
Conversation
I recently came across the same issue referenced by this PR. Are the CI failures related to this PR? From the tests, the implementation looks correct. |
@anmonteiro if you rebase this the build should pass. |
eb2eee1
to
cd56175
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look reasonable to me. Just noting this would be an API breaking change and needs a major version bump.
This looks good to me after a read through the code, but I'd like to just run it through crowbar a bit more. It should be ok for a uri.5.0 release soon. |
cd56175
to
94786d3
Compare
94786d3
to
cca065b
Compare
Could you consider merging this? We just hit this bug when trying to move to IPv6. |
mirage/ocaml-uri#169 Signed-off-by: BenjiReis <[email protected]>
@avsm We likewise had to take this change as patch into XenServer as we need it working too! BTW:
I hope this helps you to review it for merging. |
mirage/ocaml-uri#169 Signed-off-by: BenjiReis <[email protected]>
mirage/ocaml-uri#169 Signed-off-by: BenjiReis <[email protected]>
FYI I backported this fix in a previous version of the lib also presenting the IPv6 URI bug and it has indeed solved it. |
let host uri = | ||
match uri.host with | ||
| None -> None | ||
| Some (`Ipv4_literal h | `Ipv6_literal h) -> Some h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me whether the ipv6 here should be returned surrounded by square brackets. @mseri thinks it should, it would fix an issue in cohttp: mirage/ocaml-cohttp#997
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems correct, the domain part of email addresses also use brackets to delimit user-defined domains or IPv6 address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, @dinosaure: I think you refer to @mseri's proposal to fix it in ocalm-uri
as correct?: As psafont mentioned above, @mseri proposed that it should be fixed here in the uri package in his comment mirage/ocaml-cohttp#997 (comment):
I think this should be fixed in the uri package, then all dependent libraries would benefit directly from the fix.
@anmonteiro, can you have a look and update this PR to fix mirage/ocaml-cohttp#997?
Here is the link to the code location in the full review diff:
https://github.com/mirage/ocaml-uri/pull/169/files#r1330212509
I don't know Ocaml, but there is similar code (just with host
instead of h
) just in the previous diff part above: Maybe, that can be used as a starting point for updating this function:
|Some (`Ipv4_literal host) -> Buffer.add_string buf host
|Some (`Ipv6_literal host) ->
Buffer.add_char buf '[';
Buffer.add_string buf host;
Buffer.add_char buf ']'
);
It seems that this PR is highly required but it breaks the |
CHANGES: * **breaking change** Fix parsing & printing of IPv6 addresses in the host part of an uri If we follow the RFC3986 correctly, IPv6 must be surrounded by '[' and ']'. Old versions of `ocaml-uri` escaped these characters. The new version interprets these characters to recognize an IPv6 address. Users should take note of this change in behaviour, which fixes a number of bugs in HTTP requests. (@anmonteiro, review by several maintainers, mirage/ocaml-uri#169) * Upgrade tests to `ounit2` (@Alessandro-Barbieri, mirage/ocaml-uri#161)
CHANGES: * **breaking change** Fix parsing & printing of IPv6 addresses in the host part of an uri If we follow the RFC3986 correctly, IPv6 must be surrounded by '[' and ']'. Old versions of `ocaml-uri` escaped these characters. The new version interprets these characters to recognize an IPv6 address. Users should take note of this change in behaviour, which fixes a number of bugs in HTTP requests. (@anmonteiro, review by several maintainers, mirage/ocaml-uri#169) * Upgrade tests to `ounit2` (@Alessandro-Barbieri, mirage/ocaml-uri#161)
fixes #163