diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2013-12-06 08:08:28 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2013-12-06 08:08:28 -0800 |
commit | 8ef1ef1b822cdb49e72edd16a8ddbc67e5e1cf94 (patch) | |
tree | 73aa3c9b3725c4ecd022a1a70766aaace8261a8e /activesupport/test | |
parent | 747c616aa78ebc0fecc01123c6b9623f970d26bb (diff) | |
parent | a4e1e5d6329f31cb5a1ee7561fdf05dd5559ef7c (diff) | |
download | rails-8ef1ef1b822cdb49e72edd16a8ddbc67e5e1cf94.tar.gz rails-8ef1ef1b822cdb49e72edd16a8ddbc67e5e1cf94.tar.bz2 rails-8ef1ef1b822cdb49e72edd16a8ddbc67e5e1cf94.zip |
Merge pull request #10635 from vipulnsward/change_to_strict
Use `Base.strict_decode64` instead of `Base.decode64`
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/message_encryptor_test.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb index 203156baa1..b6c0a08b05 100644 --- a/activesupport/test/message_encryptor_test.rb +++ b/activesupport/test/message_encryptor_test.rb @@ -66,6 +66,17 @@ class MessageEncryptorTest < ActiveSupport::TestCase ActiveSupport.use_standard_json_time_format = prev end + def test_message_obeys_strict_encoding + bad_encoding_characters = "\n!@#" + message, iv = @encryptor.encrypt_and_sign("This is a very \n\nhumble string"+bad_encoding_characters) + + assert_not_decrypted("#{::Base64.encode64 message.to_s}--#{::Base64.encode64 iv.to_s}") + assert_not_verified("#{::Base64.encode64 message.to_s}--#{::Base64.encode64 iv.to_s}") + + assert_not_decrypted([iv, message] * bad_encoding_characters) + assert_not_verified([iv, message] * bad_encoding_characters) + end + private def assert_not_decrypted(value) @@ -81,7 +92,7 @@ class MessageEncryptorTest < ActiveSupport::TestCase end def munge(base64_string) - bits = ::Base64.decode64(base64_string) + bits = ::Base64.strict_decode64(base64_string) bits.reverse! ::Base64.strict_encode64(bits) end |