Uh oh!
There was an error while loading. Please reload this page.
std.Io.net: make HostName.validate RFC 1123-compliant - #25710
Conversation
andrewrk
commented
Oct 27, 2025
Thanks, all these new unit tests are going to be really handy when porting this logic over to #25592 🙂 |
nissarin
commented
Oct 27, 2025
There are domains with underscores in the wild. |
Based on my understanding of the relevant RFCs, that isn't standards-compliant and would challenge our definition of "valid" without loosening our interpretation. Some DNS record types also use underscores by convention, like |
nissarin
commented
Oct 27, 2025
In theory only the "hostname" can't contain underscores, everything else can and this includes not only SRV or TXT but also CNAMEs, which can point to A/AAAA records later on. In practice authoritative DNS servers (knot, nsd, and afaik windows one, whatever it's called) supports underscores, BIND hides it behind an option (at least older versions), resolvers/cache servers don't care at all. Clients support it out of the box without fuss, it's a case of "de facto standard" and going against it will break some user code. |
jparise
commented
Oct 28, 2025
I think if we can define and document the rules for allowing The existing |
The implementation of HostName.validate was too generous. It considered strings like ".example.com", "exa..mple.com", and "-example.com" to be valid hostnames, which is incorrect according to RFC 1123 (the currently accepted standard).
I re-implemented this as
|
andrewrk
commented
Jan 9, 2026
thank you, landed in efe649b13e582be855376944bac1346426e238d6 |
The implementation of HostName.validate was too generous. It considered strings like ".example.com", "exa..mple.com", and "-example.com" to be valid hostnames, which is incorrect according to RFC 1123 (the currently accepted standard). Reviewed-on: ziglang#25710
Zig 0.16's hostname validation routine is RFC 1123-compliant, so we can use it directly rather than rolling our own. Ref: https://codeberg.org/ziglang/zig/commit/efe649b13e582be855376944bac1346426e238d6 Ref: ziglang/zig#25710
Zig 0.16's hostname validation routine is RFC 1123-compliant, so we can use it directly rather than rolling our own. Ref: https://codeberg.org/ziglang/zig/commit/efe649b13e582be855376944bac1346426e238d6 Ref: ziglang/zig#25710
The implementation of HostName.validate was too generous. It considered
strings like ".example.com", "exa..mple.com", and "-example.com" to be
valid hostnames, which is incorrect according to RFC 1123 (the currently
accepted standard).