fix(headers): handle decoding errors in header values

* return original value if decoding fails
* decode base64 strings when appropriate
This commit is contained in:
Hein
2026-05-15 16:59:06 +02:00
parent cb921f2c5e
commit 51b5e909dd

View File

@@ -64,7 +64,10 @@ type ExpandOption struct {
// decodeHeaderValue decodes base64 encoded header values // decodeHeaderValue decodes base64 encoded header values
// Supports ZIP_ and __ prefixes for base64 encoding // Supports ZIP_ and __ prefixes for base64 encoding
func decodeHeaderValue(value string) string { func decodeHeaderValue(value string) string {
str, _ := DecodeParam(value) str, err := DecodeParam(value)
if err != nil {
return value
}
return str return str
} }
@@ -98,6 +101,11 @@ func DecodeParam(pStr string) (string, error) {
if strings.HasPrefix(code, "ZIP_") || strings.HasPrefix(code, "__") { if strings.HasPrefix(code, "ZIP_") || strings.HasPrefix(code, "__") {
code, _ = DecodeParam(code) code, _ = DecodeParam(code)
} else {
strDat, err := base64.StdEncoding.DecodeString(code)
if err == nil {
code = string(strDat)
}
} }
return code, nil return code, nil