@@ -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 " , '' )
@@ -44,8 +38,9 @@ def from_mail(mail, list, list_seq)
4438 self . subject = mail . subject
4539 self . subject = Kconv . toutf8 subject if self . subject
4640
47- self . from = Kconv . toutf8 mail . from_address &.raw
48- if !self . from && ( list . name == 'ruby-core' ) && ( list_seq == 161 )
41+ self . from = mail . from_address &.raw
42+ self . from = Kconv . toutf8 from if from
43+ if !from && ( list . name == 'ruby-core' ) && ( list_seq == 161 )
4944 self . from = mail . from . encode Encoding ::UTF_8 , Encoding ::KOI8_R
5045 end
5146
@@ -66,15 +61,24 @@ def from_mail(mail, list, list_seq)
6661 self
6762 end
6863
69- private def handle_multipart ( part )
70- if part . attachment?
71- file = StringIO . new ( part . decoded )
64+ private def handle_body ( part )
65+ if part . multipart?
66+ part . parts . each do |p |
67+ handle_body p
68+ end
69+ elsif part . attachment?
70+ file = StringIO . new ( part . body . raw_source )
7271 attachments . attach ( io : file , filename : part . filename , content_type : part . content_type )
7372 else
74- case part . content_type . downcase
75- when /^text\/ plain/
73+ case part . content_type &.downcase
74+ when 'application/pgp-signature'
75+ # ignore
76+ when 'application/ms-tnef'
77+ file = StringIO . new ( part . decoded )
78+ attachments . attach ( io : file , filename : part . filename || 'noname' , content_type : part . content_type )
79+ when /^text\/ plain/ , /text\/ enriched;/ , 'message/rfc822' , nil
7680 ( self . body ||= '' ) << Kconv . toutf8 ( part . body . raw_source )
77- when /^text\/ html; /
81+ when /^text\/ html/
7882 ( self . html_body ||= '' ) << Kconv . toutf8 ( part . body . raw_source )
7983 else
8084 puts "Unknown content_type: #{ part . content_type } "
0 commit comments