未验证 提交 6e0aa188 编写于 作者: C Christian Gregg 提交者: Kasper Timm Hansen

Fix Messages::Metadata#fresh? to handle parse_json_times = true

When `ActiveSupport.parse_json_times` is `true`,
`ActiveSupport::Messages::Medata.verify` will fail with a `TypeError` as
it does not pass a `String` to `Time.iso8601` as is expected.

This leads to hard-failure on retrieval of signed cookies with expiries.
上级 b305f0e2
* Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
`ActiveSupport.parse_json_times = true`.
*Christian Gregg*
* Support symbolic links for `content_path` in `ActiveSupport::EncryptedFile`.
*Takumi Shotoku*
......
......@@ -64,7 +64,7 @@ def match?(purpose)
end
def fresh?
@expires_at.nil? || Time.now.utc < Time.iso8601(@expires_at)
@expires_at.nil? || Time.now.utc < @expires_at
end
end
end
......
......@@ -61,6 +61,15 @@ def test_alternative_serialization_method
ActiveSupport.use_standard_json_time_format = prev
end
def test_verify_with_parse_json_times
previous = [ ActiveSupport.parse_json_times, Time.zone ]
ActiveSupport.parse_json_times, Time.zone = true, "UTC"
assert_equal "hi", @verifier.verify(@verifier.generate("hi", expires_at: Time.now.utc + 10))
ensure
ActiveSupport.parse_json_times, Time.zone = previous
end
def test_raise_error_when_argument_class_is_not_loaded
# To generate the valid message below:
#
......@@ -92,6 +101,7 @@ def test_backward_compatibility_messages_signed_without_metadata
assert_equal @data, @verifier.verify(signed_message)
end
def test_rotating_secret
old_message = ActiveSupport::MessageVerifier.new("old", digest: "SHA1").generate("old")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册