Strip keywords from received email body (#2436).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2426 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c687219113
commit
2d3b3cee15
@ -203,12 +203,19 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_keyword(attr, options={})
|
def get_keyword(attr, options={})
|
||||||
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i
|
@keywords ||= {}
|
||||||
|
if @keywords.has_key?(attr)
|
||||||
|
@keywords[attr]
|
||||||
|
else
|
||||||
|
@keywords[attr] = begin
|
||||||
|
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}:[ \t]*(.+)\s*$/i, '')
|
||||||
$1.strip
|
$1.strip
|
||||||
elsif !@@handler_options[:issue][attr].blank?
|
elsif !@@handler_options[:issue][attr].blank?
|
||||||
@@handler_options[:issue][attr]
|
@@handler_options[:issue][attr]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the text/plain part of the email
|
# Returns the text/plain part of the email
|
||||||
# If not found (eg. HTML-only email), returns the body with tags removed
|
# If not found (eg. HTML-only email), returns the body with tags removed
|
||||||
|
@ -49,7 +49,11 @@ class MailHandlerTest < Test::Unit::TestCase
|
|||||||
assert_equal 'New ticket on a given project', issue.subject
|
assert_equal 'New ticket on a given project', issue.subject
|
||||||
assert_equal User.find_by_login('jsmith'), issue.author
|
assert_equal User.find_by_login('jsmith'), issue.author
|
||||||
assert_equal Project.find(2), issue.project
|
assert_equal Project.find(2), issue.project
|
||||||
|
assert_equal IssueStatus.find_by_name('Resolved'), issue.status
|
||||||
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
|
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
|
||||||
|
# keywords should be removed from the email body
|
||||||
|
assert !issue.description.match(/^Project:/i)
|
||||||
|
assert !issue.description.match(/^Status:/i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_issue_with_status
|
def test_add_issue_with_status
|
||||||
@ -113,6 +117,7 @@ class MailHandlerTest < Test::Unit::TestCase
|
|||||||
issue.reload
|
issue.reload
|
||||||
assert_equal 'New ticket with custom field values', issue.subject
|
assert_equal 'New ticket with custom field values', issue.subject
|
||||||
assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
|
assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
|
||||||
|
assert !issue.description.match(/^searchable field:/i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_issue_with_cc
|
def test_add_issue_with_cc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user