mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-05-15 16:25:20 +00:00
fix(headers): handle decoding errors in header values
Some checks failed
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in -33m58s
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Successful in -33m22s
Build , Vet Test, and Lint / Lint Code (push) Failing after -33m34s
Build , Vet Test, and Lint / Build (push) Successful in -33m45s
Tests / Unit Tests (push) Failing after -34m38s
Tests / Integration Tests (push) Failing after -34m48s
Some checks failed
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in -33m58s
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Successful in -33m22s
Build , Vet Test, and Lint / Lint Code (push) Failing after -33m34s
Build , Vet Test, and Lint / Build (push) Successful in -33m45s
Tests / Unit Tests (push) Failing after -34m38s
Tests / Integration Tests (push) Failing after -34m48s
* return original value if decoding fails * decode base64 strings when appropriate
This commit is contained in:
@@ -64,7 +64,10 @@ type ExpandOption struct {
|
||||
// decodeHeaderValue decodes base64 encoded header values
|
||||
// Supports ZIP_ and __ prefixes for base64 encoding
|
||||
func decodeHeaderValue(value string) string {
|
||||
str, _ := DecodeParam(value)
|
||||
str, err := DecodeParam(value)
|
||||
if err != nil {
|
||||
return value
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
@@ -98,6 +101,11 @@ func DecodeParam(pStr string) (string, error) {
|
||||
|
||||
if strings.HasPrefix(code, "ZIP_") || strings.HasPrefix(code, "__") {
|
||||
code, _ = DecodeParam(code)
|
||||
} else {
|
||||
strDat, err := base64.StdEncoding.DecodeString(code)
|
||||
if err == nil {
|
||||
code = string(strDat)
|
||||
}
|
||||
}
|
||||
|
||||
return code, nil
|
||||
|
||||
Reference in New Issue
Block a user