- From: Anne van Kesteren <notifications@github.com>
- Date: Thu, 19 Nov 2026 04:55:05 -0800
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/397/7009706410@github.com>
annevk left a comment (whatwg/url#397)
I wrote a local web-platform-tests test to find out which hosts browsers are willing to request once the URL parser has accepted them.
For Chrome and Firefox every request went through wptserve as a proxy (using a PAC file), so no DNS was involved and the results reflect the browser's own check. Both run that same check before a normal DNS lookup. For Safari, requests went through a real lookup by the macOS resolver, pointed at wptserve's DNS server, so a failure there can come from Safari or from macOS.
| Host | Chrome 160 | Firefox 161 | Safari 27.3 |
|---|---|---|---|
| ASCII alphanumerics, `-` | ✅ | ✅ | ✅ |
| `_` | ✅ | ✅ | ✅ |
| `$`, `+` | ❌ | ✅ | ✅ |
| ``! " & ' ( ) * , ; = ` { } ~`` | ❌ | ❌ | ✅ |
| Leading or trailing `-` or `_`, labels consisting of only `-` or `_`, `ab--c` | ✅ | ✅ | ✅ |
| Last label starting with `-` or `_` | ❌ | ✅ | not tested |
| Last label ending with `-` or `_` | ✅ | ✅ | not tested |
| Empty label (`a..b`, `.a.b`, `a.b..`) | ❌ | ✅ | ❌ |
| Trailing dot | ✅ | ✅ | ✅ |
| 63-code-point label | ✅ | ✅ | ✅ |
| 64-code-point label | ❌ | ✅ | ❌ |
| 253 code points | ✅ | ✅ | ✅ |
| 254 code points | ❌ | ❌ | ✅¹ |
| 254 code points, including a trailing dot | ✅ | ❌ | ✅ |
| 255 code points, including a trailing dot | ❌ | ❌ | ✅¹ |
¹ macOS sent the DNS query even though the name exceeds DNS's 255-octet limit. wptserve's DNS server couldn't answer for a name that long, so the request itself never completed.
Observations:
* All three accept ASCII alphanumerics, `-`, and `_`. None of them restrict where `-` and `_` can appear, except that Chrome requires the last label to start with an ASCII alphanumeric.
* Firefox also accepts `$` and `+`. Safari accepts every ASCII code point the host parser allows in a domain.
* Chrome rejects empty labels, labels longer than 63 code points, and hosts longer than 253 code points (254 with a trailing dot). Safari also rejects empty labels and labels longer than 63 code points, but doesn't limit the total length. Firefox only limits the total length, to 253 code points with any trailing dot included, and leaves the rest to the resolver.
The checks are `IsCanonicalizedHostCompliant()` in Chromium (`net/base/url_util.cc`) and `net_IsValidDNSHost()` in Gecko (`netwerk/base/nsURLHelper.cpp`).
So a "DNS domain" concept along the lines of https://github.com/whatwg/url/issues/397#issuecomment-605031328 (LDH plus `_`, with hyphens allowed anywhere) would match Chrome, but would be stricter than Firefox and considerably stricter than Safari.
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/397#issuecomment-7009706410
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/url/issues/397/7009706410@github.com>
Received on Thursday, 19 November 2026 12:55:09 UTC