1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-18 13:22:55 +00:00

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: http://svn.redmine.org/redmine/trunk@17879 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-02-18 13:21:18 +00:00
parent 5329ef3b82
commit b41c5c89d4
2 changed files with 18 additions and 8 deletions

View File

@ -91,7 +91,8 @@ class MailHandler < ActionMailer::Base
@handler_options = options
sender_email = email.from.to_a.first.to_s.strip
# 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
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
end

View File

@ -765,14 +765,23 @@ class MailHandlerTest < ActiveSupport::TestCase
end
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)
assert_no_difference 'User.count' do
assert_equal false,
submit_email(
'ticket_from_emission_address.eml',
:issue => {:project => 'ecookbook'},
:unknown_user => 'create'
)
emission_addresses.each do |addr|
with_settings :mail_from => addr do
assert_no_difference 'User.count' do
assert_equal false,
submit_email(
'ticket_from_emission_address.eml',
:issue => {:project => 'ecookbook'},
:unknown_user => 'create'
)
end
end
end
end