Compare commits

..

2 Commits

Author SHA1 Message Date
Hein
cb416d49c4 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
* return original value if decoding fails
* decode base64 strings when appropriate
2026-05-15 16:59:06 +02:00
Hein
cb921f2c5e fix(websocketspec): add transaction access to HookContext 2026-05-15 14:59:34 +02:00
3 changed files with 13 additions and 1 deletions

View File

@@ -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

View File

@@ -174,6 +174,7 @@ func (h *Handler) handleRequest(conn *Connection, msg *Message) {
Options: msg.Options,
ID: recordID,
Data: msg.Data,
Tx: h.db,
Metadata: make(map[string]interface{}),
}

View File

@@ -111,6 +111,9 @@ type HookContext struct {
AbortMessage string // Message to return if aborted
AbortCode int // HTTP status code if aborted
// Tx provides access to the database/transaction for executing additional SQL
Tx common.Database
// Metadata is additional context data
Metadata map[string]interface{}
}