@@ -23,13 +23,7 @@ def from_mail(mail, list, list_seq)
2323 def from_mail ( mail , list , list_seq )
2424 self . list_id , self . list_seq , self . published_at = list . id , list_seq , mail . date
2525
26- if mail . multipart?
27- mail . parts . each do |p |
28- handle_multipart p
29- end
30- else
31- self . body = Kconv . toutf8 mail . body . raw_source
32- end
26+ handle_body mail
3327
3428 if ( ( list . name == 'ruby-dev' ) && list_seq . in? ( [ 13859 , 26229 , 39731 , 39734 ] ) ) || ( ( list . name == 'ruby-core' ) && list_seq . in? ( [ 5231 ] ) ) || ( ( list . name == 'ruby-list' ) && list_seq . in? ( [ 29637 , 29711 , 30148 ] ) ) || ( ( list . name == 'ruby-talk' ) && list_seq . in? ( [ 5198 , 61316 ] ) )
3529 self . body . gsub! ( "\u0000 " , '' )
@@ -66,16 +60,20 @@ def from_mail(mail, list, list_seq)
6660 self
6761 end
6862
69- private def handle_multipart ( part )
70- if part . attachment?
63+ private def handle_body ( part )
64+ if part . multipart?
65+ part . parts . each do |p |
66+ handle_body p
67+ end
68+ elsif part . attachment?
7169 file = StringIO . new ( part . decoded )
7270 attachments . attach ( io : file , filename : part . filename , content_type : part . content_type )
7371 else
74- case part . content_type . downcase
72+ case part . content_type & .downcase
7573 when 'application/ms-tnef'
7674 file = StringIO . new ( part . decoded )
7775 attachments . attach ( io : file , filename : part . filename || 'noname' , content_type : part . content_type )
78- when /^text\/ plain/ , /text\/ enriched;/
76+ when /^text\/ plain/ , /text\/ enriched;/ , nil
7977 ( self . body ||= '' ) << Kconv . toutf8 ( part . body . raw_source )
8078 when /^text\/ html;/
8179 ( self . html_body ||= '' ) << Kconv . toutf8 ( part . body . raw_source )
0 commit comments