Skip to content

Commit 593ea8b

Browse files
committed
reject blank JWE
1 parent 7ec09aa commit 593ea8b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/json/jwt.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ def decode_compact_serialized(jwt_string, key_or_secret, algorithms = nil, encry
108108
when JWS::NUM_OF_SEGMENTS
109109
JWS.decode_compact_serialized jwt_string, key_or_secret, algorithms, allow_blank_payload
110110
when JWE::NUM_OF_SEGMENTS
111-
JWE.decode_compact_serialized jwt_string, key_or_secret, algorithms, encryption_methods
111+
if allow_blank_payload
112+
raise InvalidFormat.new("JWE w/ blank payload is not supported.")
113+
else
114+
JWE.decode_compact_serialized jwt_string, key_or_secret, algorithms, encryption_methods
115+
end
112116
else
113117
raise InvalidFormat.new("Invalid JWT Format. JWT should include #{JWS::NUM_OF_SEGMENTS} or #{JWE::NUM_OF_SEGMENTS} segments.")
114118
end

0 commit comments

Comments
 (0)