Permalink
Browse files

Closes 20786 - TMail would fail on adding attachments if no boundary …

…was specified. Now defaults to making a new default boundary. (Andreas Schlorke)
  • Loading branch information...
mikel committed Aug 3, 2008
1 parent a579d40 commit c89e73d97d31e43f2d25c1479c841fd67b82abb1
Showing with 13 additions and 1 deletion.
  1. +1 −1 lib/tmail/mail.rb
  2. BIN test/fixtures/mailbox.zip
  3. +12 −0 test/test_attachments.rb
View
@@ -547,7 +547,7 @@ def parse_body_0( f )
end
def read_multipart( src )
- bound = @header['content-type'].params['boundary']
+ bound = @header['content-type'].params['boundary'] || ::TMail.new_boundary
is_sep = /\A--#{Regexp.quote bound}(?:--)?[ \t]*(?:\n|\r\n|\r)/
lastbound = "--#{bound}--"
View
Binary file not shown.
View
@@ -44,5 +44,17 @@ def test_decode_encoded_attachment_filename
attachment = mail.attachments.last
assert_equal "01 Quien Te Dij\212at. Pitbull.mp3", attachment.original_filename
end
+
+ def test_assigning_attachment_crashing_due_to_missing_boundary
+ mail = TMail::Mail.new
+ mail.mime_version = '1.0'
+ mail.set_content_type("multipart", "mixed")
+
+ mailpart=TMail::Mail.new
+ mailpart.set_content_type("application", "octet-stream")
+ mailpart['Content-Disposition'] = "attachment; filename=mailbox.zip"
+
+ assert_nothing_raised { mail.parts.push(mailpart) }
+ end
end

0 comments on commit c89e73d

Please sign in to comment.