Re: [whatwg/url] Allow `[` and `]` as URL code-points (Issue #753)

> No one ever escapes [ and ] in host, but:
> - Only Go, Chrome, Python urlparse accept it
> - Python urllib3, libcurl, and current spec reject it as invalid
> - Node.js' legacy url parser does something weird (inserts a / before the [)

Aye, the host behaviour is a bit annoying.

- Both Go parsers seem to have weird behaviour where they strip square brackets if the entire host is enclosed by a matching pair (so `[host]` becomes `host`), but otherwise they keep them (`ho[s]t` remains as-is). Maybe that's intentional, but honestly it looks more like an oversight.

- libcurl is overly strict, and rejects plenty of hostnames which RFC-3986 (which I assume it is supposed to follow) would consider valid. For example, 3986's host may be a `reg-name`, which may contain `sub-delims`. And yet, it [fails to parse](https://timothygu.me/urltester/#input=x%3A%2F%2Fhost%3D2%2F) a hostname containing the `=` sign (which is an allowed subdelim), while all others allow it.

- For this standard, even if they were allowed they would only apply to opaque hostnames (i.e. for non-special schemes), because special schemes must have either a domain/IPv4/IPv6 host.

  They could technically be allowed, and I think there _would_ be value in allowing it, but in order to stop your host sometimes being interpreted as an IPv6 address, we'd need to either ban matching brackets enclosing the address (e.g. `[host]` would not be allowed, but `ho[st]` would), or just stop parsing IPv6 addresses in opaque hostnames altogether and let the application decide when that interpretation is appropriate (which is totally fair - opaque URL components are extremely valuable for encoding custom data. But right now it's opaque-except-nonopaque-when-IPv6; maybe we should just let it be truly opaque and drop the weird special case).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/753#issuecomment-1441235409
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/753/1441235409@github.com>

Received on Thursday, 23 February 2023 05:28:06 UTC