summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-01 15:32:34 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-01 15:32:34 +0000
commitab46c52d4a3e993d3ca59cca976e1235ee2e2ed7 (patch)
tree84fd57049aad6690562bf44efae0e3cc130301ee
parent2df6c99e675d3edaa2aac2e473cfee2304afa5cf (diff)
downloadredmine-ab46c52d4a3e993d3ca59cca976e1235ee2e2ed7.tar.gz
redmine-ab46c52d4a3e993d3ca59cca976e1235ee2e2ed7.zip
MailHandler: fixed that sender's fullname is not unquoted (#10334).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9043 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mail_handler.rb2
-rw-r--r--test/fixtures/mail_handler/fullname_of_sender_as_utf8_encoded.eml5
-rw-r--r--test/unit/mail_handler_test.rb15
3 files changed, 21 insertions, 1 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 8e8d6568f..9c9665183 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -384,7 +384,7 @@ class MailHandler < ActionMailer::Base
def create_user_from_email
addr = email.from_addrs.to_a.first
if addr && !addr.spec.blank?
- user = self.class.new_user_from_attributes(addr.spec, addr.name)
+ user = self.class.new_user_from_attributes(addr.spec, TMail::Unquoter.unquote_and_convert_to(addr.name, 'utf-8'))
if user.save
user
else
diff --git a/test/fixtures/mail_handler/fullname_of_sender_as_utf8_encoded.eml b/test/fixtures/mail_handler/fullname_of_sender_as_utf8_encoded.eml
new file mode 100644
index 000000000..ac14b44f9
--- /dev/null
+++ b/test/fixtures/mail_handler/fullname_of_sender_as_utf8_encoded.eml
@@ -0,0 +1,5 @@
+From: =?utf-8?b?w4TDpCDDlsO2?= <foo@example.org>
+Subject: foo
+Content-Type: text/plain; charset=utf-8
+
+testing user creation with quoted From-header
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 92dc43113..218625f74 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -576,6 +576,21 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal 'foo+bar@example.net', user.mail
end
+ def test_new_user_with_utf8_encoded_fullname_should_be_decoded
+ assert_difference 'User.count' do
+ issue = submit_email(
+ 'fullname_of_sender_as_utf8_encoded.eml',
+ :issue => {:project => 'ecookbook'},
+ :unknown_user => 'create'
+ )
+ end
+
+ user = User.first(:order => 'id DESC')
+ assert_equal "foo@example.org", user.mail
+ assert_equal "Ää", user.firstname
+ assert_equal "Öö", user.lastname
+ end
+
private
def submit_email(filename, options={})