summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-14 20:43:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-14 20:43:15 +0000
commit9b971925db934ae7fdc81477d6c0754b70266b76 (patch)
tree8045a113cdd2399065dc60c02a531b6e14963cca
parentc12ba8a76cfa54b2f980017a1ca4a5d28bf8ce5d (diff)
downloadredmine-9b971925db934ae7fdc81477d6c0754b70266b76.tar.gz
redmine-9b971925db934ae7fdc81477d6c0754b70266b76.zip
Ignore bogus issue strings like [some-string#1234] in email subjects (#17705).
git-svn-id: http://svn.redmine.org/redmine/trunk@13593 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mail_handler.rb2
-rw-r--r--test/unit/mail_handler_test.rb24
2 files changed, 25 insertions, 1 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index be737931c..b502a86d7 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -145,7 +145,7 @@ class MailHandler < ActionMailer::Base
private
MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
- ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
+ ISSUE_REPLY_SUBJECT_RE = %r{\[(?:[^\]]*\s+)?#(\d+)\]}
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
def dispatch
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 6d250a4e2..d774eeedd 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -663,6 +663,30 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal 'Feature request', journal.issue.tracker.name
end
+ def test_update_issue_should_accept_issue_id_after_space_inside_brackets
+ journal = submit_email('ticket_reply_with_status.eml') do |email|
+ assert email.sub!(/^Subject:.*$/, "Subject: Re: [Feature request #2] Add ingredients categories")
+ end
+ assert journal.is_a?(Journal)
+ assert_equal Issue.find(2), journal.journalized
+ end
+
+ def test_update_issue_should_accept_issue_id_inside_brackets
+ journal = submit_email('ticket_reply_with_status.eml') do |email|
+ assert email.sub!(/^Subject:.*$/, "Subject: Re: [#2] Add ingredients categories")
+ end
+ assert journal.is_a?(Journal)
+ assert_equal Issue.find(2), journal.journalized
+ end
+
+ def test_update_issue_should_ignore_bogus_issue_ids_in_subject
+ journal = submit_email('ticket_reply_with_status.eml') do |email|
+ assert email.sub!(/^Subject:.*$/, "Subject: Re: [12345#1][bogus#1][Feature request #2] Add ingredients categories")
+ end
+ assert journal.is_a?(Journal)
+ assert_equal Issue.find(2), journal.journalized
+ end
+
def test_update_issue_with_attribute_changes
# This email contains: 'Status: Resolved'
journal = submit_email('ticket_reply_with_status.eml')