diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-10-09 02:26:08 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-10-09 02:26:18 +0100 |
commit | 69aa5e8a86b1d33e057076dc6049e37c92b0e50f (patch) | |
tree | e7ce80a5aa90c9ac71060812f7454558671377bb /activesupport | |
parent | 992c2db76cd6cd6aa9a6ba3711a6ea1ad8910062 (diff) | |
download | rails-69aa5e8a86b1d33e057076dc6049e37c92b0e50f.tar.gz rails-69aa5e8a86b1d33e057076dc6049e37c92b0e50f.tar.bz2 rails-69aa5e8a86b1d33e057076dc6049e37c92b0e50f.zip |
Ensure MessageVerifier raises appropriate exception on tampered data
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/message_verifier.rb | 2 | ||||
-rw-r--r-- | activesupport/test/message_verifier_test.rb | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb index fcdc09ff08..282346b1a6 100644 --- a/activesupport/lib/active_support/message_verifier.rb +++ b/activesupport/lib/active_support/message_verifier.rb @@ -29,7 +29,7 @@ module ActiveSupport raise InvalidSignature if signed_message.blank? data, digest = signed_message.split("--") - if secure_compare(digest, generate_digest(data)) + if data.present? && digest.present? && secure_compare(digest, generate_digest(data)) Marshal.load(ActiveSupport::Base64.decode64(data)) else raise InvalidSignature diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb index e6370bc3db..ef300e4e26 100644 --- a/activesupport/test/message_verifier_test.rb +++ b/activesupport/test/message_verifier_test.rb @@ -27,6 +27,7 @@ class MessageVerifierTest < Test::Unit::TestCase data, hash = @verifier.generate(@data).split("--") assert_not_verified("#{data.reverse}--#{hash}") assert_not_verified("#{data}--#{hash.reverse}") + assert_not_verified("purejunk") end def assert_not_verified(message) |