Compare commits

...

1 Commits

Author SHA1 Message Date
Matthew Holt d6f2a05f8d caddyhttp: Normalize hosts in provision 2026-02-18 09:03:49 -07:00
+1 -3
View File
@@ -262,13 +262,11 @@ func (m MatchHost) Provision(_ caddy.Context) error {
if err != nil { if err != nil {
return fmt.Errorf("converting hostname '%s' to ASCII: %v", host, err) return fmt.Errorf("converting hostname '%s' to ASCII: %v", host, err)
} }
if asciiHost != host {
m[i] = asciiHost
}
normalizedHost := strings.ToLower(asciiHost) normalizedHost := strings.ToLower(asciiHost)
if firstI, ok := seen[normalizedHost]; ok { if firstI, ok := seen[normalizedHost]; ok {
return fmt.Errorf("host at index %d is repeated at index %d: %s", firstI, i, host) return fmt.Errorf("host at index %d is repeated at index %d: %s", firstI, i, host)
} }
m[i] = normalizedHost // normalize for all comparisons while matching
seen[normalizedHost] = i seen[normalizedHost] = i
} }