Commit de2cac25 authored by maeda's avatar maeda

Mail handler does not ignore emails sent from emission email address if...

Mail handler does not ignore emails sent from emission email address if Setting.mail_from includes display name (#30785).

Patch by Go MAEDA.


git-svn-id: https://svn.redmine.org/redmine/trunk@17879 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 6eef4b51
...@@ -91,7 +91,8 @@ class MailHandler < ActionMailer::Base ...@@ -91,7 +91,8 @@ class MailHandler < ActionMailer::Base
@handler_options = options @handler_options = options
sender_email = email.from.to_a.first.to_s.strip sender_email = email.from.to_a.first.to_s.strip
# Ignore emails received from the application emission address to avoid hell cycles # Ignore emails received from the application emission address to avoid hell cycles
if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0 emission_address = Setting.mail_from.to_s.gsub(/(?:.*<|>.*|\(.*\))/, '').strip
if sender_email.casecmp(emission_address) == 0
if logger if logger
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
end end
......
...@@ -765,14 +765,23 @@ class MailHandlerTest < ActiveSupport::TestCase ...@@ -765,14 +765,23 @@ class MailHandlerTest < ActiveSupport::TestCase
end end
def test_should_ignore_emails_from_emission_address def test_should_ignore_emails_from_emission_address
emission_addresses = [
'redmine@example.net',
'Redmine <redmine@example.net>',
'redmine@example.net (Redmine)'
]
Role.anonymous.add_permission!(:add_issues) Role.anonymous.add_permission!(:add_issues)
assert_no_difference 'User.count' do emission_addresses.each do |addr|
assert_equal false, with_settings :mail_from => addr do
submit_email( assert_no_difference 'User.count' do
'ticket_from_emission_address.eml', assert_equal false,
:issue => {:project => 'ecookbook'}, submit_email(
:unknown_user => 'create' 'ticket_from_emission_address.eml',
) :issue => {:project => 'ecookbook'},
:unknown_user => 'create'
)
end
end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment