summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-21 20:44:19 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-21 20:44:19 +0000
commit8c7ae204020d2502a9f14d30e955fa42c837261e (patch)
tree507fa52053393f32ce4ce36121e0f507236e660f
parent06b68f194811325d7d4a33fe942af478d5c3786f (diff)
downloadredmine-8c7ae204020d2502a9f14d30e955fa42c837261e.tar.gz
redmine-8c7ae204020d2502a9f14d30e955fa42c837261e.zip
Merged r10850 from trunk (#12396).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.1-stable@10861 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mail_handler.rb5
-rw-r--r--test/fixtures/mail_handler/no_subject_header.eml10
-rw-r--r--test/unit/mail_handler_test.rb9
3 files changed, 22 insertions, 2 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 1927a3c57..e53c877d7 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -124,6 +124,7 @@ class MailHandler < ActionMailer::Base
def dispatch
headers = [email.in_reply_to, email.references].flatten.compact
+ subject = email.subject.to_s
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
klass, object_id = $1, $2.to_i
method_name = "receive_#{klass}_reply"
@@ -132,9 +133,9 @@ class MailHandler < ActionMailer::Base
else
# ignoring it
end
- elsif m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
+ elsif m = subject.match(ISSUE_REPLY_SUBJECT_RE)
receive_issue_reply(m[1].to_i)
- elsif m = email.subject.match(MESSAGE_REPLY_SUBJECT_RE)
+ elsif m = subject.match(MESSAGE_REPLY_SUBJECT_RE)
receive_message_reply(m[1].to_i)
else
dispatch_to_default
diff --git a/test/fixtures/mail_handler/no_subject_header.eml b/test/fixtures/mail_handler/no_subject_header.eml
new file mode 100644
index 000000000..e6538cbb9
--- /dev/null
+++ b/test/fixtures/mail_handler/no_subject_header.eml
@@ -0,0 +1,10 @@
+Content-Type: application/ms-tnef; name="winmail.dat"
+Content-Transfer-Encoding: binary
+From: John Smith <JSmith@somenet.foo>
+To: "redmine@somenet.foo" <redmine@somenet.foo>
+Date: Fri, 1 Jun 2012 14:39:38 +0200
+Message-ID: <87C31D42249DD0489D1A1444E3232DD7019D6183@foo.bar>
+Accept-Language: de-CH, en-US
+Content-Language: de-CH
+
+Fixture
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 6bbb12d4c..e88fd1563 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -467,6 +467,15 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal ja, issue.subject
end
+ def test_add_issue_with_no_subject_header
+ issue = submit_email(
+ 'no_subject_header.eml',
+ :issue => {:project => 'ecookbook'}
+ )
+ assert_kind_of Issue, issue
+ assert_equal '(no subject)', issue.subject
+ end
+
def test_add_issue_with_mixed_japanese_subject
issue = submit_email(
'subject_japanese_2.eml',