Skip to content

Commit 26bee1e

Browse files
committed
Give attachment with no name a name "noname"
1 parent f81edc6 commit 26bee1e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/models/message.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def from_mail(mail, list, list_seq)
6262
end
6363

6464
private def handle_body(part)
65+
debugger
6566
if part.multipart?
6667
part.parts.each do |p|
6768
handle_body p
@@ -80,8 +81,12 @@ def from_mail(mail, list, list_seq)
8081
(self.body ||= ''.dup) << Kconv.toutf8(part.body.raw_source)
8182
when /^text\/html/
8283
(self.html_body ||= ''.dup) << Kconv.toutf8(part.body.raw_source)
84+
when 'application/octet-stream'
85+
# there can be an attachment with nil part.filename (which is equivalent to part.attachment?).
86+
file = StringIO.new(part.decoded)
87+
attachments.attach(io: file, filename: part.filename || 'noname', content_type: part.content_type)
8388
else
84-
puts "Unknown content_type: #{part.content_type}"
89+
raise "Unknown content_type: #{part.content_type}"
8590
end
8691
end
8792
end

0 commit comments

Comments
 (0)