Package: ruby-tmail Version: 1.2.7.1-3 Severity: important Justification: regression over Squeeze and affects Schleuder Control: tags -1 + patch
The following test case shows that TMail currently wrongly parses unquoted attachment filenames: --- 8< --- require 'tmail' m = TMail::Mail.parse(<<END_OF_MESSAGE) Content-Type: text/x-diff; charset=utf-8 Content-Transfer-Encoding: Quoted-printable Content-Disposition: attachment; filename=statuts.diff Test END_OF_MESSAGE p m['content-type'] p m['content-disposition'] puts m.to_s --- >8 --- Outputs: --- 8< --- #<TMail::ContentTypeHeader "text/x-diff; charset=utf-8\n"> #<TMail::ContentDispositionHeader "attachment; filename=statuts.diff\n"> Content-Type: text/x-diff; charset=utf-8 Content-Transfer-Encoding: Quoted-printable Content-Disposition: attachment; filename="statuts.diff " Test --- >8 --- The same test case does not insert the '\n"' sequence with version 1.2.3 in Squeeze. After bisecting upstream changes, it looks like this was introduced by the following commit: <https://github.com/mikel/tmail/commit/d3f1d826df44e83287c690d58194f54b42500b0d> The attached patch adds a test case and fix the issue by properly striping the newline. This is an important issue as without a fix, Schleuder chokes (as in raising an error) on a good deal of emails which worked perfectly fine on Squeeze. -- Jérémy Bobbio .''`. [email protected] : :Ⓐ : # apt-get install anarchism `. `'` `-
Description: Fix parsing of unquoted attachment filenames Upstream commit d3f1d826 introduced a problem when parsing Content-Disposition headers with unquoted filenames. Author: Jérémy Bobbio <[email protected]> Last-Update: 2013-04-24 lib/tmail/utils.rb | 2 +- test/test_attachments.rb | 1 + test/test_mail.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/lib/tmail/utils.rb b/lib/tmail/utils.rb index 68e5898..5c395d3 100644 --- a/lib/tmail/utils.rb +++ b/lib/tmail/utils.rb @@ -350,7 +350,7 @@ module TMail head, should_quoted, tail = $~.captures # head: "; name=" # should_quoted: "=?ISO-2022-JP?B?...=?=" - head << quote_token(should_quoted) << tail + head << quote_token(should_quoted.strip) << tail } end diff --git a/test/test_attachments.rb b/test/test_attachments.rb index 86dcb40..72f53d0 100644 --- a/test/test_attachments.rb +++ b/test/test_attachments.rb @@ -79,6 +79,7 @@ HERE fixture = File.read(File.dirname(__FILE__) + "/fixtures/unquoted_filename_in_attachment") mail = TMail::Mail.parse(fixture) assert_equal("image/png", mail.attachments.first.content_type) + assert_equal("Picture 7.png", mail.attachments.first.original_filename) end def test_unquoted_apple_mail_content_type diff --git a/test/test_mail.rb b/test/test_mail.rb index b63f497..52f26da 100644 --- a/test/test_mail.rb +++ b/test/test_mail.rb @@ -530,6 +530,17 @@ EOF assert_equal(output, mail.to_s) end + def test_mail_to_s_with_unquoted_filename + msg = <<EOF +From: [email protected] +Subject: =?utf-8?Q?testing_testing_=D6=A4?= +Content-Disposition: attachment; filename=README.txt.pif + +The body +EOF + assert_equal(msg, TMail::Mail.parse(msg).to_s) + end + def test_mail_to_s_with_filename_discards_quotes_as_needed msg = <<EOF From: [email protected] --
signature.asc
Description: Digital signature

