From fb0c262f8f4535689004b9e443628ea0555d93c0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 24 May 2014 16:29:46 +0000 Subject: [PATCH] Merged r13126 (#16619). git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13155 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mailer.rb | 2 +- test/unit/mailer_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 1ded8d6ea..8be6f83fd 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -464,7 +464,7 @@ class Mailer < ActionMailer::Base if rand hash << Redmine::Utils.random_hex(8) end - host = Setting.mail_from.to_s.gsub(%r{^.*@}, '') + host = Setting.mail_from.to_s.strip.gsub(%r{^.*@|>}, '') host = "#{::Socket.gethostname}.redmine" if host.empty? "#{hash.join('.')}@#{host}" end diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index 8d661fc51..983e9fc4f 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -650,6 +650,12 @@ class MailerTest < ActiveSupport::TestCase assert ActionMailer::Base.perform_deliveries end + def test_token_for_should_strip_trailing_gt_from_address_with_full_name + with_settings :mail_from => "Redmine Mailer" do + assert_match /\Aredmine.issue-\d+\.\d+\.[0-9a-f]+@redmine.org\z/, Mailer.token_for(Issue.generate!) + end + end + def test_layout_should_include_the_emails_header with_settings :emails_header => "*Header content*" do with_settings :plain_text_mail => 0 do -- 2.39.5