Defect #30785 » 30785-fix.diff
| app/models/mail_handler.rb (working copy) | ||
|---|---|---|
| 91 | 91 | @handler_options = options | 
| 92 | 92 | sender_email = email.from.to_a.first.to_s.strip | 
| 93 | 93 | # Ignore emails received from the application emission address to avoid hell cycles | 
| 94 |     if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0 | |
| 94 |     if sender_email.casecmp(Setting.mail_from_address) == 0 | |
| 95 | 95 | if logger | 
| 96 | 96 |         logger.info  "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" | 
| 97 | 97 | end | 
| app/models/setting.rb (working copy) | ||
|---|---|---|
| 228 | 228 | Object.const_defined?(:OpenID) && self[:openid].to_i > 0 | 
| 229 | 229 | end | 
| 230 |   # Extracts an email address ("joe@example.com") from | |
| 231 |   # Setting.mail_from ("Joe Bloggs <joe@example.com>") | |
| 232 | def self.mail_from_address | |
| 233 | self.mail_from.to_s.gsub(/(?:.*<|>.*|\(.*\))/, '').strip | |
| 234 | end | |
| 235 | ||
| 230 | 236 | # Checks if settings have changed since the values were read | 
| 231 | 237 | # and clears the cache hash if it's the case | 
| 232 | 238 | # Called once per request | 
| test/unit/setting_test.rb (working copy) | ||
|---|---|---|
| 112 | 112 | end | 
| 113 | 113 | end | 
| 114 | def test_mail_from_address | |
| 115 | mail_from_strings = [ | |
| 116 | 'joe@example.com', | |
| 117 | '<joe@example.com>', | |
| 118 | 'Joe Bloggs <joe@example.com>', | |
| 119 | 'display_name@example.com <joe@example.com>', | |
| 120 | 'joe@example.com (Joe Bloggs)', | |
| 121 | 'joe@example.com (display_name@example.com)' | |
| 122 | ] | |
| 123 | ||
| 124 | mail_from_strings.each do |from_value| | |
| 125 | with_settings :mail_from => from_value do | |
| 126 | assert_equal 'joe@example.com', Setting.mail_from_address | |
| 127 | end | |
| 128 | end | |
| 129 | end | |
| 130 | ||
| 114 | 131 | def test_setting_serialied_as_binary_should_be_loaded_as_utf8_encoded_strings | 
| 115 | 132 | yaml = <<-YAML | 
| 116 | 133 | --- |