Browse Source

Address#to_s changes the input passed to it - dup before calling.

Otherwise UTF-8 encoded strings will be returned as ASCII-8BIT.
hotfix/0.21.0.35
Louise Crow 6 years ago
parent
commit
52bc4b39a3
  1. 6
      lib/mail_handler/backends/mail_backend.rb
  2. 17
      spec/lib/mail_handler/backends/mail_backend_spec.rb

6
lib/mail_handler/backends/mail_backend.rb

@ -362,11 +362,11 @@ module MailHandler
raise "invalid email " + email + " passed to address_from_name_and_email"
end
if name.nil?
return Mail::Address.new(email).to_s
return Mail::Address.new(email.dup).to_s
end
address = Mail::Address.new
address.display_name = name
address.address = email
address.display_name = name.dup
address.address = email.dup
address.to_s
end

17
spec/lib/mail_handler/backends/mail_backend_spec.rb

@ -142,4 +142,21 @@ DOC
end
describe :address_from_name_and_email do
it 'returns an address string' do
expected = 'Test User <test@example.com>'
address_from_name_and_email('Test User', 'test@example.com').should == expected
end
it 'does not change the name passed to it' do
original = "brønn"
name = original.dup
address_from_name_and_email(name, 'test@example.com')
name.should == original
end
end
end

Loading…
Cancel
Save