caddyhttp: Normalize (lowercase) {label.N} placeholders

This commit is contained in:
Matthew Holt 2025-08-25 13:18:13 -06:00
parent b866a9e099
commit e0a8f9541d
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -289,7 +289,7 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo
return prefix.String(), true
}
// hostname labels
// hostname labels (case insensitive, so normalize to lowercase)
if strings.HasPrefix(key, reqHostLabelsReplPrefix) {
idxStr := key[len(reqHostLabelsReplPrefix):]
idx, err := strconv.Atoi(idxStr)
@ -304,7 +304,7 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo
if idx >= len(hostLabels) {
return "", true
}
return hostLabels[len(hostLabels)-idx-1], true
return strings.ToLower(hostLabels[len(hostLabels)-idx-1]), true
}
// path parts