From a19d0f5a66f17c356c5255c5d5930a73a25f627a Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Tue, 27 Dec 2011 22:46:44 +0300 Subject: deprecate Base64.encode64s from AS. Use Base64.strict_encode64 instead --- activesupport/lib/active_support/base64.rb | 6 +++++- activesupport/lib/active_support/message_encryptor.rb | 2 +- activesupport/lib/active_support/message_verifier.rb | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb index b43d2ce9a3..41a1a3469d 100644 --- a/activesupport/lib/active_support/base64.rb +++ b/activesupport/lib/active_support/base64.rb @@ -3,12 +3,16 @@ require 'base64' module ActiveSupport Base64 = ::Base64 + # *DEPRECATED*: Use +Base64.strict_encode64+ instead. + # # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters # or memcache keys without further processing. # # ActiveSupport::Base64.encode64s("Original unencoded string") # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==" def Base64.encode64s(value) - encode64(value).gsub(/\n/, '') + ActiveSupport::Deprecation.warn "encode64s " \ + "is deprecated. Use Base64.strict_encode64 instead", caller + strict_encode64(value) end end diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index 7d8a7fb687..476ba0b3d1 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -56,7 +56,7 @@ module ActiveSupport encrypted_data = cipher.update(@serializer.dump(value)) encrypted_data << cipher.final - [encrypted_data, iv].map {|v| ActiveSupport::Base64.encode64s(v)}.join("--") + [encrypted_data, iv].map {|v| ActiveSupport::Base64.strict_encode64(v)}.join("--") end def _decrypt(encrypted_message) diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb index 30ac44f6fa..7cb5b1e82d 100644 --- a/activesupport/lib/active_support/message_verifier.rb +++ b/activesupport/lib/active_support/message_verifier.rb @@ -18,7 +18,7 @@ module ActiveSupport # self.current_user = User.find(id) # end # - # By default it uses Marshal to serialize the message. If you want to use another + # By default it uses Marshal to serialize the message. If you want to use another # serialization method, you can set the serializer attribute to something that responds # to dump and load, e.g.: # @@ -44,7 +44,7 @@ module ActiveSupport end def generate(value) - data = ActiveSupport::Base64.encode64s(@serializer.dump(value)) + data = ActiveSupport::Base64.strict_encode64(@serializer.dump(value)) "#{data}--#{generate_digest(data)}" end -- cgit v1.2.3