From 36f5e45c2568c73d8a0f0647598d3cd52b5bfabd Mon Sep 17 00:00:00 2001 From: danielgrippi <danielgrippi@gmail.com> Date: Wed, 31 Aug 2011 16:26:02 -0700 Subject: [PATCH] change Base64.encode64 to Base64.encode64s (encode without newlines) --- app/views/publics/webfinger.erb | 2 +- lib/diaspora/encryptable.rb | 2 +- lib/encryptor.rb | 8 ++++---- lib/postzord/dispatcher.rb | 2 +- lib/salmon/salmon.rb | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index cc6c64b369..c462a13fe1 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -9,5 +9,5 @@ <Link rel='http://webfinger.net/rel/profile-page' type='text/html' <%="#{person_href(@person, :absolute => true)}"%>/> <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.public_url%>.atom"/> - <Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64(@person.exported_key)%>"/> + <Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64s(@person.exported_key)%>"/> </XRD> diff --git a/lib/diaspora/encryptable.rb b/lib/diaspora/encryptable.rb index a950e38f56..75bcca4e2c 100644 --- a/lib/diaspora/encryptable.rb +++ b/lib/diaspora/encryptable.rb @@ -26,7 +26,7 @@ module Diaspora # @param [OpenSSL::PKey::RSA] key An RSA key # @return [String] A Base64 encoded signature of #signable_string with key def sign_with_key(key) - sig = Base64.encode64(key.sign "SHA", signable_string) + sig = Base64.encode64s(key.sign "SHA", signable_string) log_hash = {:event => :sign_with_key, :status => :complete} log_hash.merge(:model_id => self.id) if self.respond_to?(:persisted?) Rails.logger.info(log_hash) diff --git a/lib/encryptor.rb b/lib/encryptor.rb index a75dc7ba62..0ade6d1b18 100644 --- a/lib/encryptor.rb +++ b/lib/encryptor.rb @@ -9,14 +9,14 @@ module Encryptor ciphertext = aes_encrypt(cleartext, aes_key) encrypted_key = encrypt_aes_key aes_key cipher_hash = {:aes_key => encrypted_key, :ciphertext => ciphertext} - Base64.encode64( cipher_hash.to_json ) + Base64.encode64s( cipher_hash.to_json ) end def gen_aes_key cipher = OpenSSL::Cipher.new('AES-256-CBC') key = cipher.random_key iv = cipher.random_iv - {'key' => Base64.encode64(key), 'iv' => Base64.encode64(iv)} + {'key' => Base64.encode64s(key), 'iv' => Base64.encode64(iv)} end def aes_encrypt(txt, key) @@ -27,11 +27,11 @@ module Encryptor ciphertext = '' ciphertext << cipher.update(txt) ciphertext << cipher.final - Base64.encode64 ciphertext + Base64.encode64s(ciphertext) end def encrypt_aes_key key - Base64.encode64 public_key.public_encrypt( key.to_json ) + Base64.encode64s(public_key.public_encrypt( key.to_json )) end end diff --git a/lib/postzord/dispatcher.rb b/lib/postzord/dispatcher.rb index 8d5e5b0fa6..01649d87bc 100644 --- a/lib/postzord/dispatcher.rb +++ b/lib/postzord/dispatcher.rb @@ -152,7 +152,7 @@ class Postzord::Dispatcher # @param remote_people [Array<Person>] Recipients of the post on other pods # @return [void] def queue_remote_delivery_job(remote_people) - Resque.enqueue(Jobs::HttpMulti, @sender.id, Base64.encode64(@object.to_diaspora_xml), remote_people.map{|p| p.id}, self.class.to_s) + Resque.enqueue(Jobs::HttpMulti, @sender.id, Base64.encode64s(@object.to_diaspora_xml), remote_people.map{|p| p.id}, self.class.to_s) end end diff --git a/lib/salmon/salmon.rb b/lib/salmon/salmon.rb index 20c7c750b3..aa0dd4b1de 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon/salmon.rb @@ -17,6 +17,7 @@ module Base64 # ArgumentError is raised if +str+ is incorrectly padded or contains # non-alphabet characters. Note that CR or LF are also rejected. def strict_decode64(str) + Rails.logger.info("trying to decode string: " + str) str.unpack("m0").first end -- GitLab