@@ -0,0 +1,5 | |||||
|
1 | From: =?utf-8?b?w4TDpCDDlsO2?= <foo@example.org> | |||
|
2 | Subject: foo | |||
|
3 | Content-Type: text/plain; charset=utf-8 | |||
|
4 | ||||
|
5 | testing user creation with quoted From-header |
@@ -384,7 +384,7 class MailHandler < ActionMailer::Base | |||||
384 | def create_user_from_email |
|
384 | def create_user_from_email | |
385 | addr = email.from_addrs.to_a.first |
|
385 | addr = email.from_addrs.to_a.first | |
386 | if addr && !addr.spec.blank? |
|
386 | if addr && !addr.spec.blank? | |
387 | user = self.class.new_user_from_attributes(addr.spec, addr.name) |
|
387 | user = self.class.new_user_from_attributes(addr.spec, TMail::Unquoter.unquote_and_convert_to(addr.name, 'utf-8')) | |
388 | if user.save |
|
388 | if user.save | |
389 | user |
|
389 | user | |
390 | else |
|
390 | else |
@@ -576,6 +576,21 class MailHandlerTest < ActiveSupport::TestCase | |||||
576 | assert_equal 'foo+bar@example.net', user.mail |
|
576 | assert_equal 'foo+bar@example.net', user.mail | |
577 | end |
|
577 | end | |
578 |
|
578 | |||
|
579 | def test_new_user_with_utf8_encoded_fullname_should_be_decoded | |||
|
580 | assert_difference 'User.count' do | |||
|
581 | issue = submit_email( | |||
|
582 | 'fullname_of_sender_as_utf8_encoded.eml', | |||
|
583 | :issue => {:project => 'ecookbook'}, | |||
|
584 | :unknown_user => 'create' | |||
|
585 | ) | |||
|
586 | end | |||
|
587 | ||||
|
588 | user = User.first(:order => 'id DESC') | |||
|
589 | assert_equal "foo@example.org", user.mail | |||
|
590 | assert_equal "Ää", user.firstname | |||
|
591 | assert_equal "Öö", user.lastname | |||
|
592 | end | |||
|
593 | ||||
579 | private |
|
594 | private | |
580 |
|
595 | |||
581 | def submit_email(filename, options={}) |
|
596 | def submit_email(filename, options={}) |
General Comments 0
You need to be logged in to leave comments.
Login now