]> source.dussan.org Git - redmine.git/commitdiff
Fixed: crypting blank passwords raises an error (#9137).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 29 Nov 2011 19:47:51 +0000 (19:47 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 29 Nov 2011 19:47:51 +0000 (19:47 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7985 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/ciphering.rb
test/unit/lib/redmine/ciphering_test.rb

index 959aa71c37705b20c24e39e9532bf4bde2f170e4..3dd5df826564cf0f09446518e3703e1bfaee3647 100644 (file)
@@ -23,7 +23,7 @@ module Redmine
 
     class << self
       def encrypt_text(text)
-        if cipher_key.blank?
+        if cipher_key.blank? || text.blank?
           text
         else
           c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
index 6c0e0e36809d1581843e1971db56b9c619417ebf..94d40116e30c851c151a7f836d3292cf9215f3ee 100644 (file)
@@ -43,6 +43,14 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
     end
   end
 
+  def test_blank_password_should_be_clear
+    Redmine::Configuration.with 'database_cipher_key' => 'secret' do
+      r = Repository::Subversion.generate!(:password => '')
+      assert_equal '', r.password
+      assert_equal '', r.read_attribute(:password)
+    end
+  end
+
   def test_unciphered_password_should_be_readable
     Redmine::Configuration.with 'database_cipher_key' => nil do
       r = Repository::Subversion.generate!(:password => 'clear')