Project

General

Profile

Defect #30785 » 30785-fix.diff

Go MAEDA, 2019-02-12 13:06

View differences:

app/models/mail_handler.rb (working copy)
@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
if sender_email.casecmp(Setting.mail_from_address) == 0
if logger
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
end
app/models/setting.rb (working copy)
Object.const_defined?(:OpenID) && self[:openid].to_i > 0
end
# Extracts an email address ("joe@example.com") from
# Setting.mail_from ("Joe Bloggs <joe@example.com>")
def self.mail_from_address
self.mail_from.to_s.gsub(/(?:.*<|>.*|\(.*\))/, '').strip
end
# Checks if settings have changed since the values were read
# and clears the cache hash if it's the case
# Called once per request
test/unit/setting_test.rb (working copy)
end
end
def test_mail_from_address
mail_from_strings = [
'joe@example.com',
'<joe@example.com>',
'Joe Bloggs <joe@example.com>',
'display_name@example.com <joe@example.com>',
'joe@example.com (Joe Bloggs)',
'joe@example.com (display_name@example.com)'
]
mail_from_strings.each do |from_value|
with_settings :mail_from => from_value do
assert_equal 'joe@example.com', Setting.mail_from_address
end
end
end
def test_setting_serialied_as_binary_should_be_loaded_as_utf8_encoded_strings
yaml = <<-YAML
---
(1-1/2)