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
This commit is contained in:
Jean-Philippe Lang 2012-03-01 15:32:34 +00:00
parent 2df6c99e67
commit ab46c52d4a
3 changed files with 21 additions and 1 deletions

View File

@ -384,7 +384,7 @@ class MailHandler < ActionMailer::Base
def create_user_from_email def create_user_from_email
addr = email.from_addrs.to_a.first addr = email.from_addrs.to_a.first
if addr && !addr.spec.blank? 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 if user.save
user user
else else

View File

@ -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

View File

@ -576,6 +576,21 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal 'foo+bar@example.net', user.mail assert_equal 'foo+bar@example.net', user.mail
end 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 private
def submit_email(filename, options={}) def submit_email(filename, options={})