mirror of https://github.com/rails/rails
Merge pull request #49669 from intrip/fix-message-metadata-non-str
Fix decoding data encoded using a non-String purpose
This commit is contained in:
commit
9ade3f9b56
|
@ -82,7 +82,7 @@ module ActiveSupport
|
|||
throw :invalid_message_content, "expired"
|
||||
end
|
||||
|
||||
if hash["pur"] != purpose&.to_s
|
||||
if hash["pur"].to_s != purpose.to_s
|
||||
throw :invalid_message_content, "mismatched purpose"
|
||||
end
|
||||
|
||||
|
|
|
@ -92,6 +92,13 @@ module MessageMetadataTests
|
|||
assert_roundtrip "a string", codec, { purpose: "x", expires_in: 1.year }, { purpose: "x" }
|
||||
end
|
||||
|
||||
test "messages with non-string purpose are readable" do
|
||||
each_scenario do |data, codec|
|
||||
message = encode(data, codec, purpose: [ "x", 1 ])
|
||||
assert_equal data, decode(message, codec, purpose: [ "x", 1 ])
|
||||
end
|
||||
end
|
||||
|
||||
test "messages are readable regardless of use_message_serializer_for_metadata" do
|
||||
each_scenario do |data, codec|
|
||||
message = encode(data, codec, purpose: "x")
|
||||
|
|
Loading…
Reference in New Issue