Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Fix panic on null (but present) header key
Browse files Browse the repository at this point in the history
  • Loading branch information
csstaub committed Jun 26, 2018
1 parent 8cff744 commit 6954638
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions jwe_test.go
Expand Up @@ -541,3 +541,9 @@ func TestSampleJose4jJWEMessagesECDH(t *testing.T) {
}
}
}

func TestJWEWithNullAlg(t *testing.T) {
// {"alg":null,"enc":"A128GCM"}
serialized := `{"protected":"eyJhbGciOm51bGwsImVuYyI6IkExMjhHQ00ifQ"}`
ParseEncrypted(serialized)
}
2 changes: 1 addition & 1 deletion shared.go
Expand Up @@ -206,7 +206,7 @@ func (parsed rawHeader) set(k HeaderKey, v interface{}) error {
// getString gets a string from the raw JSON, defaulting to "".
func (parsed rawHeader) getString(k HeaderKey) string {
v, ok := parsed[k]
if !ok {
if !ok || v == nil {
return ""
}
var s string
Expand Down

0 comments on commit 6954638

Please sign in to comment.