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

Trim surrounding [] from uri host before join host port #314

Closed
wants to merge 1 commit into from

Conversation

dsonck92
Copy link

@dsonck92 dsonck92 commented Jun 15, 2023

As is mandatory for raw IPv6 addresses in URLs, square brackets are present around the host. Strip these before attempting to split or join. If a port is present, the raw IPv6 address will not have a trailing ], so it will maintain the brackets.

Closes #313

As is mandatory for raw IPv6 addresses, square brackets are present
around the host. Strip these before attempting to split or join.
If a port is present, the raw IPv6 address will not have a trailing
`]`, so it will maintain the brackets.
@Achilleshiel
Copy link
Contributor

This is a bug caused by using the side-effect from SplitHostPort. IPv6 addresses in URLs must be within square brackets. SplitHostPort and JoinHostPort are created for IPAddresses. Not for hosts in the URL.

@aler9
Copy link
Member

aler9 commented Jun 15, 2023

Hello, from what i've understood you want to support these kind of URLs, in which the port is missing and the IP is surrounded by square brackets:

rtsp://[::1]/mydata

Square brackets are not mandatory, however those URLs are legit. I just don't understood why this is not handled by the standard Go library.

@Achilleshiel
Copy link
Contributor

A literal IPv6 address in a URL should be in square brackets RFC.
SplitHostPort is created for literal ips not for URLS. For literal IPs outside of URL context IPv6 only gets square brackets in combination with a port-suffix.
In this situation we are working with an URL, thus url.URL{}.Port() should be used.

@aler9
Copy link
Member

aler9 commented Jun 17, 2023

Fixed by #316, see answer in #315 (comment)

@aler9 aler9 closed this Jun 17, 2023
@dsonck92 dsonck92 deleted the fix-raw-ipv6-support branch June 19, 2023 10:21
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raw IPv6 addresses in URI are not properly supported
3 participants