summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-18 18:13:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-18 18:13:13 +0000
commitd4297ca3ff309a63737e2d12adb4ea1ec0085828 (patch)
tree8d651cecfa58d887cbd6f1bddd5ccd49a8d77caf
parent0ee2af4c063ec9b7c353ee9928b8ebdc8f805b48 (diff)
downloadredmine-d4297ca3ff309a63737e2d12adb4ea1ec0085828.tar.gz
redmine-d4297ca3ff309a63737e2d12adb4ea1ec0085828.zip
Fixed that text/plain attachments are added to issue description (#15684).
git-svn-id: http://svn.redmine.org/redmine/trunk@12420 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mail_handler.rb5
-rw-r--r--test/fixtures/mail_handler/multiple_text_parts.eml7
-rw-r--r--test/unit/mail_handler_test.rb10
3 files changed, 21 insertions, 1 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 3c9857873..c100f8d97 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -405,6 +405,11 @@ class MailHandler < ActionMailer::Base
else
[email]
end
+
+ parts.reject! do |part|
+ part.header[:content_disposition].try(:disposition_type) == 'attachment'
+ end
+
@plain_text_body = parts.map {|p| Redmine::CodesetUtil.to_utf8(p.body.decoded, p.charset)}.join("\r\n")
# strip html tags and remove doctype directive
diff --git a/test/fixtures/mail_handler/multiple_text_parts.eml b/test/fixtures/mail_handler/multiple_text_parts.eml
index c61bcb786..794caa354 100644
--- a/test/fixtures/mail_handler/multiple_text_parts.eml
+++ b/test/fixtures/mail_handler/multiple_text_parts.eml
@@ -52,4 +52,11 @@ Content-Type: text/plain;
The third one.
+--Apple-Mail=_33C8180A-B097-4B87-A925-441300BDB9C9
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: attachment; filename="textfile.txt"
+
+Plain text attachment
+
--Apple-Mail=_33C8180A-B097-4B87-A925-441300BDB9C9--
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 7e0f80cf3..785d16ffd 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -501,13 +501,21 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest
end
- def test_multiple_text_parts
+ def test_multiple_inline_text_parts_should_be_appended_to_issue_description
issue = submit_email('multiple_text_parts.eml', :issue => {:project => 'ecookbook'})
assert_include 'first', issue.description
assert_include 'second', issue.description
assert_include 'third', issue.description
end
+ def test_attachment_text_part_should_be_added_as_issue_attachment
+ issue = submit_email('multiple_text_parts.eml', :issue => {:project => 'ecookbook'})
+ assert_not_include 'Plain text attachment', issue.description
+ attachment = issue.attachments.detect {|a| a.filename == 'textfile.txt'}
+ assert_not_nil attachment
+ assert_include 'Plain text attachment', File.read(attachment.diskfile)
+ end
+
def test_add_issue_with_iso_8859_1_subject
issue = submit_email(
'subject_as_iso-8859-1.eml',