os/hostname: switch to std.Io.net.HostName.validate

Zig 0.16's hostname validation routine is RFC 1123-compliant, so we can
use it directly rather than rolling our own.

Ref: efe649b13e
Ref: https://github.com/ziglang/zig/pull/25710
This commit is contained in:
Jon Parise
2026-07-23 08:15:06 -04:00
parent ab0b9da9e8
commit e663d54051
2 changed files with 2 additions and 87 deletions

View File

@@ -411,9 +411,9 @@ pub fn isValidCacheKey(key: []const u8) bool {
fn isValidHost(host: []const u8) bool {
// First check for valid hostnames because this is assumed to be the more
// likely ssh host format.
if (internal_os.hostname.isValid(host)) {
if (std.Io.net.HostName.validate(host)) |_| {
return true;
}
} else |_| {}
// We also accept valid IP addresses. In practice, IPv4 addresses are also
// considered valid hostnames due to their overlapping syntax, so we can