From fd24250be09e54fcbfaff1ab524f2d9796835299 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 29 Nov 2011 19:47:51 +0000 Subject: [PATCH] Fixed: crypting blank passwords raises an error (#9137). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7985 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/ciphering.rb | 2 +- test/unit/lib/redmine/ciphering_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/redmine/ciphering.rb b/lib/redmine/ciphering.rb index 959aa71c3..3dd5df826 100644 --- a/lib/redmine/ciphering.rb +++ b/lib/redmine/ciphering.rb @@ -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") diff --git a/test/unit/lib/redmine/ciphering_test.rb b/test/unit/lib/redmine/ciphering_test.rb index 6c0e0e368..94d40116e 100644 --- a/test/unit/lib/redmine/ciphering_test.rb +++ b/test/unit/lib/redmine/ciphering_test.rb @@ -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') -- 2.39.5