sisimai 4.22.4 → 4.22.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sisimai might be problematic. Click here for more details.

Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +13 -0
  3. data/README-JA.md +2 -2
  4. data/README.md +2 -2
  5. data/lib/sisimai.rb +2 -2
  6. data/lib/sisimai/arf.rb +1 -1
  7. data/lib/sisimai/bite/email.rb +11 -0
  8. data/lib/sisimai/bite/email/amazonses.rb +1 -1
  9. data/lib/sisimai/bite/email/ezweb.rb +4 -2
  10. data/lib/sisimai/bite/email/google.rb +3 -3
  11. data/lib/sisimai/bite/email/gsuite.rb +2 -2
  12. data/lib/sisimai/bite/email/interscanmss.rb +1 -1
  13. data/lib/sisimai/bite/email/kddi.rb +1 -0
  14. data/lib/sisimai/bite/email/mcafee.rb +1 -1
  15. data/lib/sisimai/bite/email/opensmtpd.rb +4 -4
  16. data/lib/sisimai/bite/email/outlook.rb +1 -1
  17. data/lib/sisimai/bite/email/x1.rb +1 -1
  18. data/lib/sisimai/bite/email/x3.rb +2 -2
  19. data/lib/sisimai/bite/json/amazonses.rb +1 -1
  20. data/lib/sisimai/data/json.rb +1 -1
  21. data/lib/sisimai/message/email.rb +8 -22
  22. data/lib/sisimai/order/email.rb +9 -27
  23. data/lib/sisimai/reason/contenterror.rb +10 -16
  24. data/lib/sisimai/reason/exceedlimit.rb +2 -2
  25. data/lib/sisimai/reason/expired.rb +17 -19
  26. data/lib/sisimai/reason/hasmoved.rb +2 -2
  27. data/lib/sisimai/reason/hostunknown.rb +17 -24
  28. data/lib/sisimai/reason/mailboxfull.rb +47 -66
  29. data/lib/sisimai/reason/mesgtoobig.rb +15 -20
  30. data/lib/sisimai/reason/networkerror.rb +18 -23
  31. data/lib/sisimai/reason/norelaying.rb +15 -21
  32. data/lib/sisimai/reason/notaccept.rb +5 -6
  33. data/lib/sisimai/reason/policyviolation.rb +19 -22
  34. data/lib/sisimai/reason/rejected.rb +46 -51
  35. data/lib/sisimai/reason/suspend.rb +16 -23
  36. data/lib/sisimai/reason/systemerror.rb +20 -29
  37. data/lib/sisimai/reason/systemfull.rb +5 -6
  38. data/lib/sisimai/reason/toomanyconn.rb +16 -21
  39. data/lib/sisimai/reason/vacation.rb +7 -9
  40. data/lib/sisimai/reason/virusdetected.rb +7 -8
  41. data/lib/sisimai/version.rb +1 -1
  42. data/set-of-emails/maildir/bsd/arf-14.eml +58 -319
  43. data/set-of-emails/maildir/bsd/email-postfix-32.eml +72 -0
  44. data/set-of-emails/maildir/bsd/rfc3834-01.eml +22 -36
  45. metadata +3 -72
  46. data/set-of-emails/maildir/bsd/README.md +0 -327
  47. data/set-of-emails/maildir/bsd/arf-15.eml +0 -66
  48. data/set-of-emails/maildir/bsd/email-exchange2007-02.eml +0 -252
  49. data/set-of-emails/maildir/bsd/email-exchange2007-03.eml +0 -1178
  50. data/set-of-emails/maildir/bsd/email-exim-09.eml +0 -169
  51. data/set-of-emails/maildir/bsd/email-exim-10.eml +0 -718
  52. data/set-of-emails/maildir/bsd/email-exim-11.eml +0 -718
  53. data/set-of-emails/maildir/bsd/email-exim-12.eml +0 -75
  54. data/set-of-emails/maildir/bsd/email-exim-13.eml +0 -145
  55. data/set-of-emails/maildir/bsd/email-exim-14.eml +0 -32
  56. data/set-of-emails/maildir/bsd/email-exim-15.eml +0 -49
  57. data/set-of-emails/maildir/bsd/email-exim-16.eml +0 -98
  58. data/set-of-emails/maildir/bsd/email-exim-17.eml +0 -50
  59. data/set-of-emails/maildir/bsd/email-exim-18.eml +0 -96
  60. data/set-of-emails/maildir/bsd/email-exim-19.eml +0 -52
  61. data/set-of-emails/maildir/bsd/email-exim-20.eml +0 -159
  62. data/set-of-emails/maildir/bsd/email-exim-21.eml +0 -150
  63. data/set-of-emails/maildir/bsd/email-exim-22.eml +0 -50
  64. data/set-of-emails/maildir/bsd/email-exim-23.eml +0 -57
  65. data/set-of-emails/maildir/bsd/email-exim-24.eml +0 -107
  66. data/set-of-emails/maildir/bsd/email-exim-25.eml +0 -18
  67. data/set-of-emails/maildir/bsd/email-exim-26.eml +0 -111
  68. data/set-of-emails/maildir/bsd/email-exim-27.eml +0 -120
  69. data/set-of-emails/maildir/bsd/email-exim-28.eml +0 -148
  70. data/set-of-emails/maildir/bsd/email-google-12.eml +0 -76
  71. data/set-of-emails/maildir/bsd/email-google-13.eml +0 -79
  72. data/set-of-emails/maildir/bsd/email-imailserver-05.eml +0 -92
  73. data/set-of-emails/maildir/bsd/email-interscanmss-02.eml +0 -259
  74. data/set-of-emails/maildir/bsd/email-notes-04.eml +0 -181
  75. data/set-of-emails/maildir/bsd/email-postfix-18.eml +0 -121
  76. data/set-of-emails/maildir/bsd/email-postfix-19.eml +0 -105
  77. data/set-of-emails/maildir/bsd/email-postfix-20.eml +0 -231
  78. data/set-of-emails/maildir/bsd/email-postfix-22.eml +0 -73
  79. data/set-of-emails/maildir/bsd/email-postfix-23.eml +0 -75
  80. data/set-of-emails/maildir/bsd/email-postfix-24.eml +0 -73
  81. data/set-of-emails/maildir/bsd/email-postfix-25.eml +0 -73
  82. data/set-of-emails/maildir/bsd/email-postfix-26.eml +0 -73
  83. data/set-of-emails/maildir/bsd/email-postfix-27.eml +0 -66
  84. data/set-of-emails/maildir/bsd/email-qmail-09.eml +0 -103
  85. data/set-of-emails/maildir/bsd/email-qmail-10.eml +0 -32
  86. data/set-of-emails/maildir/bsd/email-qmail-11.eml +0 -73
  87. data/set-of-emails/maildir/bsd/email-qmail-12.eml +0 -24
  88. data/set-of-emails/maildir/bsd/email-sendmail-23.eml +0 -137
  89. data/set-of-emails/maildir/bsd/email-x2-05.eml +0 -98
  90. data/set-of-emails/maildir/bsd/email-x4-01.eml +0 -92
  91. data/set-of-emails/maildir/bsd/email-x4-02.eml +0 -112
  92. data/set-of-emails/maildir/bsd/email-x4-03.eml +0 -245
  93. data/set-of-emails/maildir/bsd/email-x4-04.eml +0 -81
  94. data/set-of-emails/maildir/bsd/email-x4-05.eml +0 -121
  95. data/set-of-emails/maildir/bsd/email-x4-06.eml +0 -32
  96. data/set-of-emails/maildir/bsd/rfc3464-10.eml +0 -467
  97. data/set-of-emails/maildir/bsd/rfc3464-11.eml +0 -1171
  98. data/set-of-emails/maildir/bsd/rfc3464-12.eml +0 -101
  99. data/set-of-emails/maildir/bsd/rfc3464-13.eml +0 -131
  100. data/set-of-emails/maildir/bsd/rfc3464-14.eml +0 -121
  101. data/set-of-emails/maildir/bsd/rfc3464-15.eml +0 -144
  102. data/set-of-emails/maildir/bsd/rfc3464-16.eml +0 -36
  103. data/set-of-emails/maildir/bsd/rfc3464-17.eml +0 -109
  104. data/set-of-emails/maildir/bsd/rfc3464-18.eml +0 -149
  105. data/set-of-emails/maildir/bsd/rfc3464-19.eml +0 -65
  106. data/set-of-emails/maildir/bsd/rfc3464-20.eml +0 -145
  107. data/set-of-emails/maildir/bsd/rfc3464-21.eml +0 -146
  108. data/set-of-emails/maildir/bsd/rfc3464-24.eml +0 -27
  109. data/set-of-emails/maildir/bsd/rfc3464-30.eml +0 -1173
  110. data/set-of-emails/maildir/bsd/rfc3464-31.eml +0 -141
  111. data/set-of-emails/maildir/bsd/rfc3464-32.eml +0 -158
  112. data/set-of-emails/maildir/bsd/rfc3834-02.eml +0 -51
  113. data/set-of-emails/maildir/bsd/rfc3834-03.eml +0 -33
  114. data/set-of-emails/maildir/bsd/rfc3834-04.eml +0 -29
  115. data/set-of-emails/maildir/bsd/rfc3834-05.eml +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d77b9e4c9f85d9c719c82e92a91d56a2dd504b10
4
- data.tar.gz: 1b7309ee1aaedaa7a5119dc371d8ca1fdd5b1a10
3
+ metadata.gz: 383458bf9c7149bd37111bb9f8c3a447e8077a6c
4
+ data.tar.gz: a145574332b0193f166ac827a9f55ef1d4c21f6f
5
5
  SHA512:
6
- metadata.gz: 26a656c7a48b5785f0515ad3c2df2ab595dc826f1c2a94cefa30f5eccd4f94b99b9449b853b0d8c1b760fb1f4299708cdd20ae57bd329267eb862d5ad4ba08a1
7
- data.tar.gz: a4a6f09a0b3cf3e005a3acc8076bdbdae0ce598cc4efd20b7a374b6c3db56307f436ba1a723b9984afb42c9d00dda686d90179edc46d905c9974fd6ad6b74206
6
+ metadata.gz: e453822ac07cf13914b0f62ad02ef664e8f020d22a5c15f5947788f5e7588b4f17b3debfbbbd23d55b3207cd8ee18367c783f7c69976225959b56a81e7cc25e1
7
+ data.tar.gz: 93550044f8ee76e04dc4c8d9a53dfe0a1215d4c0f980ec60a9f7ffb4ab61dba857ce6ae511a9a51c7a56edd20de6f9aea0e0d7987009da3e989374b203053d4b
@@ -3,6 +3,19 @@ RELEASE NOTES for Ruby version of Sisimai
3
3
  - releases: "https://github.com/sisimai/rb-Sisimai/releases"
4
4
  - download: "https://rubygems.org/gems/sisimai"
5
5
 
6
+ v4.22.5
7
+ --------------------------------------------------------------------------------
8
+ - release: "Fri, 30 Mar 2018 12:29:36 +0900 (JST)"
9
+ - version: "4.22.5"
10
+ - changes:
11
+ - #112 The order to load MTA modules improvement.
12
+ - Sample emails in set-of-emails/ which are not owned by Sisimai project have
13
+ been removed.
14
+ - Update error message patterns in Sisimai::Reason::Expired.
15
+ - Less regular expression in each child class of Sisimai::Reason #113.
16
+ - Pre-Updates for au.com, the new domain of EZweb from Apr 2018 announced at
17
+ http://news.kddi.com/kddi/corporate/newsrelease/2017/08/22/2637.html #114
18
+
6
19
  v4.22.4
7
20
  --------------------------------------------------------------------------------
8
21
  - release: "Wed, 14 Feb 2018 10:44:00 +0900 (JST)"
@@ -239,8 +239,8 @@ Differences between Ruby version and Perl version
239
239
  | メール解析速度(1000通のメール) | 5.05秒 | 1.95秒 |
240
240
  | インストール方法 | gem install | cpanm, cpm |
241
241
  | 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
242
- | LOC:ソースコードの行数 | 12000行 | 8700行 |
243
- | テスト件数(spec/,t/,xt/ディレクトリ) | 213000件 | 230000件 |
242
+ | LOC:ソースコードの行数 | 12000行 | 8600行 |
243
+ | テスト件数(spec/,t/,xt/ディレクトリ) | 207000件 | 224000件 |
244
244
  | ライセンス | 二条項BSD | 二条項BSD |
245
245
  | 開発会社によるサポート契約 | 準備中 | 提供中 |
246
246
 
data/README.md CHANGED
@@ -243,8 +243,8 @@ and bounceHammer are available at
243
243
  | The speed of parsing email(1000 emails) | 5.05s | 1.95s |
244
244
  | How to install | gem install | cpanm, cpm |
245
245
  | Dependencies (Except core modules) | 1 module | 2 modules |
246
- | LOC:Source lines of code | 12000 lines | 8700 lines |
247
- | The number of tests(spec/,t/,xt/) directory | 213000 tests | 230000 tests |
246
+ | LOC:Source lines of code | 12000 lines | 8600 lines |
247
+ | The number of tests(spec/,t/,xt/) directory | 207000 tests | 224000 tests |
248
248
  | License | BSD 2-Clause | BSD 2-Clause |
249
249
  | Support Contract provided by Developer | Coming soon | Available |
250
250
 
@@ -31,7 +31,7 @@ module Sisimai
31
31
 
32
32
  input = argv1[:input] || nil
33
33
  field = argv1[:field] || []
34
- raise ' ***error: "field" accepts an array reference only' unless field.is_a? Array
34
+ raise ' ***error: "field" accepts an array only' unless field.is_a? Array
35
35
 
36
36
  unless input
37
37
  # "input" did not specified, try to detect automatically.
@@ -114,7 +114,7 @@ module Sisimai
114
114
  return nil unless argv0
115
115
 
116
116
  nyaan = Sisimai.make(argv0, argv1) || []
117
- if RUBY_PLATFORM.include?('java')
117
+ if RUBY_PLATFORM.start_with?('java')
118
118
  # java-based ruby environment like JRuby.
119
119
  require 'jrjackson'
120
120
  jsonstring = JrJackson::Json.dump(nyaan)
@@ -46,7 +46,7 @@ module Sisimai
46
46
  # Content-Type: multipart/report; report-type=feedback-report; ...
47
47
  match = true
48
48
 
49
- elsif heads['content-type'].include?('multipart/mixed')
49
+ elsif heads['content-type'].start_with?('multipart/mixed')
50
50
  # Microsoft (Hotmail, MSN, Live, Outlook) uses its own report format.
51
51
  # Amazon SES Complaints bounces
52
52
  mfrom = %r{(?:
@@ -30,6 +30,17 @@ module Sisimai
30
30
  X1 X2 X3 X4 X5 V5sendmail FML]
31
31
  end
32
32
 
33
+ # @abstract MTA list which have one or more extra headers
34
+ # @return [Array] MTA list (have extra headers)
35
+ def heads
36
+ return %w[
37
+ Exim Exchange2007 Exchange2003 Google GSuite Office365 Outlook SendGrid
38
+ AmazonSES ReceivingSES AmazonWorkMail Aol GMX MailRu MessageLabs Yahoo
39
+ Yandex Zoho EinsUndEins MXLogic McAfee MFILTER EZweb Activehunter IMailServer
40
+ SurfControl FML
41
+ ]
42
+ end
43
+
33
44
  # @abstract Parse bounce messages
34
45
  # @param [Hash] mhead Message header of a bounce email
35
46
  # @options mhead [String] from From header
@@ -41,7 +41,7 @@ module Sisimai::Bite::Email
41
41
 
42
42
  # :from => %r/\AMAILER-DAEMON[@]email[-]bounces[.]amazonses[.]com\z/,
43
43
  # :subject => %r/\ADelivery Status Notification [(]Failure[)]\z/,
44
- return nil if mhead['x-mailer'].to_s.include?('Amazon WorkMail')
44
+ return nil if mhead['x-mailer'].to_s.start_with?('Amazon WorkMail')
45
45
 
46
46
  match = 0
47
47
  match += 1 if mhead['x-aws-outgoing']
@@ -59,10 +59,12 @@ module Sisimai::Bite::Email
59
59
 
60
60
  match = 0
61
61
  match += 1 if mhead['from'].include?('Postmaster@ezweb.ne.jp')
62
+ match += 1 if mhead['from'].include?('Postmaster@au.com')
62
63
  match += 1 if mhead['subject'] == 'Mail System Error - Returned Mail'
63
64
  match += 1 if mhead['received'].find { |a| a.include?('ezweb.ne.jp (EZweb Mail) with') }
65
+ match += 1 if mhead['received'].find { |a| a.include?('.au.com (') }
64
66
  if mhead['message-id']
65
- match += 1 if mhead['message-id'].end_with?('.ezweb.ne.jp>')
67
+ match += 1 if mhead['message-id'].end_with?('.ezweb.ne.jp>', '.au.com>')
66
68
  end
67
69
  return nil if match < 2
68
70
 
@@ -227,7 +229,7 @@ module Sisimai::Bite::Email
227
229
  # The value of "reason" is not set yet.
228
230
  # Deal as "userunknown" when the domain part of the recipient
229
231
  # is "ezweb.ne.jp".
230
- e['reason'] = 'userunknown' unless e['recipient'].end_with?('@ezweb.ne.jp')
232
+ e['reason'] = 'userunknown' unless e['recipient'].end_with?('@ezweb.ne.jp', '@au.com')
231
233
  end
232
234
  e['agent'] = self.smtpagent
233
235
  end
@@ -173,8 +173,8 @@ module Sisimai::Bite::Email
173
173
  # The error that the other server returned was:
174
174
  # 550 5.1.1 <userunknown@example.jp>... User Unknown
175
175
  #
176
- return nil unless mhead['from'].include?('<mailer-daemon@googlemail.com>')
177
- return nil unless mhead['subject'].include?('Delivery Status Notification')
176
+ return nil unless mhead['from'].end_with?('<mailer-daemon@googlemail.com>')
177
+ return nil unless mhead['subject'].start_with?('Delivery Status Notification')
178
178
 
179
179
  require 'sisimai/address'
180
180
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
@@ -189,7 +189,7 @@ module Sisimai::Bite::Email
189
189
  while e = hasdivided.shift do
190
190
  if readcursor.zero?
191
191
  # Beginning of the bounce message or delivery status part
192
- readcursor |= Indicators[:deliverystatus] if e.include?(StartingOf[:message][0])
192
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
193
193
  end
194
194
 
195
195
  if (readcursor & Indicators[:'message-rfc822']).zero?
@@ -38,8 +38,8 @@ module Sisimai::Bite::Email
38
38
  return nil unless mhead
39
39
  return nil unless mbody
40
40
 
41
- return nil unless mhead['from'].include?('<mailer-daemon@googlemail.com>')
42
- return nil unless mhead['subject'].include?('Delivery Status Notification')
41
+ return nil unless mhead['from'].end_with?('<mailer-daemon@googlemail.com>')
42
+ return nil unless mhead['subject'].start_with?('Delivery Status Notification')
43
43
  return nil unless mhead['x-gm-message-state']
44
44
 
45
45
  require 'sisimai/address'
@@ -41,7 +41,7 @@ module Sisimai::Bite::Email
41
41
  # メール配信に失敗しました
42
42
  '=?iso-2022-jp?B?GyRCJWEhPCVrR1s/LiRLPDpHVCQ3JF4kNyQ/GyhCDQo=?=',
43
43
  ]
44
- match += 1 if mhead['from'].include?('InterScan MSS')
44
+ match += 1 if mhead['from'].start_with?('"InterScan MSS"')
45
45
  match += 1 if tryto.find { |a| mhead['subject'] == a }
46
46
  return nil if match.zero?
47
47
 
@@ -45,6 +45,7 @@ module Sisimai::Bite::Email
45
45
  match += 1 if mhead['from'] =~ /no-reply[@].+[.]dion[.]ne[.]jp/
46
46
  match += 1 if mhead['reply-to'].to_s == 'no-reply@app.auone-net.jp'
47
47
  match += 1 if mhead['received'].find { |a| a.include?('ezweb.ne.jp (') }
48
+ match += 1 if mhead['received'].find { |a| a.include?('.au.com (') }
48
49
  return nil if match.zero?
49
50
 
50
51
  require 'sisimai/string'
@@ -34,7 +34,7 @@ module Sisimai::Bite::Email
34
34
  return nil unless mhead
35
35
  return nil unless mbody
36
36
  return nil unless mhead['x-nai-header']
37
- return nil unless mhead['x-nai-header'].include?('Modified by McAfee ')
37
+ return nil unless mhead['x-nai-header'].start_with?('Modified by McAfee ')
38
38
  return nil unless mhead['subject'] == 'Delivery Status'
39
39
 
40
40
  require 'sisimai/address'
@@ -33,8 +33,8 @@ module Sisimai::Bite::Email
33
33
  # bounce.c/337:const char *notice_relay =
34
34
  # bounce.c/338: " Your message was relayed to these recipients.\n\n";
35
35
  # bounce.c/339:
36
- message: [' This is the MAILER-DAEMON, please DO NOT REPLY to this '],
37
- rfc822: [' Below is a copy of the original message:'],
36
+ message: [' This is the MAILER-DAEMON, please DO NOT REPLY to this '],
37
+ rfc822: [' Below is a copy of the original message:'],
38
38
  }.freeze
39
39
  ReFailures = {
40
40
  # smtpd/queue.c:221| envelope_set_errormsg(&evp, "Envelope expired");
@@ -97,7 +97,7 @@ module Sisimai::Bite::Email
97
97
  while e = hasdivided.shift do
98
98
  if readcursor.zero?
99
99
  # Beginning of the bounce message or delivery status part
100
- if e.include?(StartingOf[:message][0])
100
+ if e.start_with?(StartingOf[:message][0])
101
101
  readcursor |= Indicators[:deliverystatus]
102
102
  next
103
103
  end
@@ -105,7 +105,7 @@ module Sisimai::Bite::Email
105
105
 
106
106
  if (readcursor & Indicators[:'message-rfc822']).zero?
107
107
  # Beginning of the original message part
108
- if e.include?(StartingOf[:rfc822][0])
108
+ if e.start_with?(StartingOf[:rfc822][0])
109
109
  readcursor |= Indicators[:'message-rfc822']
110
110
  next
111
111
  end
@@ -41,7 +41,7 @@ module Sisimai::Bite::Email
41
41
 
42
42
  # :from => %r/postmaster[@]/,
43
43
  match = 0
44
- match += 1 if mhead['subject'].include?('Delivery Status Notification')
44
+ match += 1 if mhead['subject'].start_with?('Delivery Status Notification')
45
45
  match += 1 if mhead['x-message-delivery']
46
46
  match += 1 if mhead['x-message-info']
47
47
  match += 1 if mhead['received'].find { |a| a.include?('.hotmail.com') }
@@ -31,7 +31,7 @@ module Sisimai::Bite::Email
31
31
  return nil unless mhead
32
32
  return nil unless mbody
33
33
  return nil unless mhead['subject'].start_with?('Returned Mail: ')
34
- return nil unless mhead['from'].include?('"Mail Deliver System" ')
34
+ return nil unless mhead['from'].start_with?('"Mail Deliver System" ')
35
35
 
36
36
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
37
37
  hasdivided = mbody.split("\n")
@@ -8,7 +8,7 @@ module Sisimai::Bite::Email
8
8
 
9
9
  Indicators = Sisimai::Bite::Email.INDICATORS
10
10
  StartingOf = {
11
- message: [' This is an automatically generated Delivery Status Notification'],
11
+ message: [' This is an automatically generated Delivery Status Notification.'],
12
12
  rfc822: ['Content-Type: message/rfc822'],
13
13
  }.freeze
14
14
 
@@ -44,7 +44,7 @@ module Sisimai::Bite::Email
44
44
  while e = hasdivided.shift do
45
45
  if readcursor.zero?
46
46
  # Beginning of the bounce message or delivery status part
47
- if e.include?(StartingOf[:message][0])
47
+ if e.start_with?(StartingOf[:message][0])
48
48
  readcursor |= Indicators[:deliverystatus]
49
49
  next
50
50
  end
@@ -68,7 +68,7 @@ module Sisimai::Bite::JSON
68
68
  end
69
69
 
70
70
  begin
71
- if RUBY_PLATFORM.include?('java')
71
+ if RUBY_PLATFORM.start_with?('java')
72
72
  # java-based ruby environment like JRuby.
73
73
  require 'jrjackson'
74
74
  jsonobject = JrJackson::Json.load(jsonstring)
@@ -13,7 +13,7 @@ module Sisimai
13
13
  return nil unless argvs
14
14
  return nil unless argvs.is_a? Sisimai::Data
15
15
 
16
- if RUBY_PLATFORM.include?('java')
16
+ if RUBY_PLATFORM.start_with?('java')
17
17
  # java-based ruby environment like JRuby.
18
18
  begin
19
19
  require 'jrjackson'
@@ -278,9 +278,10 @@ module Sisimai
278
278
 
279
279
  # Try to match the value of "Subject" with patterns generated by
280
280
  # Sisimai::Order->by('subject') method
281
+ title = heads['subject'].downcase
281
282
  SubjectTab.each_key do |e|
282
283
  # Get MTA list from the subject header
283
- next unless heads['subject'] =~ e
284
+ next unless title.include?(e)
284
285
 
285
286
  # Matched and push MTA list
286
287
  order.concat(SubjectTab[e])
@@ -485,12 +486,7 @@ module Sisimai
485
486
  tobeloaded.each do |r|
486
487
  # Call user defined MTA modules
487
488
  next if haveloaded[r]
488
- begin
489
- require r.gsub('::', '/').downcase
490
- rescue LoadError => ce
491
- warn ' ***warning: Failed to load ' << ce.to_s
492
- next
493
- end
489
+ #require r.gsub('::', '/').downcase
494
490
  scannedset = Module.const_get(r).scan(mailheader, bodystring)
495
491
  haveloaded[r] = true
496
492
  throw :SCANNER if scannedset
@@ -500,12 +496,7 @@ module Sisimai
500
496
  # Try MTA module candidates which are detected from MTA specific
501
497
  # mail headers on first
502
498
  next if haveloaded.key?(r)
503
- begin
504
- require r.gsub('::', '/').downcase
505
- rescue LoadError => ce
506
- warn ' ***warning: ' << ce.to_s
507
- next
508
- end
499
+ require r.gsub('::', '/').downcase
509
500
  scannedset = Module.const_get(r).scan(mailheader, bodystring)
510
501
  haveloaded[r] = true
511
502
  throw :SCANNER if scannedset
@@ -515,15 +506,10 @@ module Sisimai
515
506
  # MTA modules which does not have MTA specific header and did
516
507
  # not match with any regular expressions of Subject header.
517
508
  next if haveloaded.key?(r)
518
- begin
519
- require r.gsub('::', '/').downcase
520
- scannedset = Module.const_get(r).scan(mailheader, bodystring)
521
- haveloaded[r] = true
522
- throw :SCANNER if scannedset
523
- rescue => ce
524
- warn ' ***warning: ' << ce.to_s
525
- next
526
- end
509
+ require r.gsub('::', '/').downcase
510
+ scannedset = Module.const_get(r).scan(mailheader, bodystring)
511
+ haveloaded[r] = true
512
+ throw :SCANNER if scannedset
527
513
  end
528
514
 
529
515
  # When the all of Sisimai::Bite::Email::* modules did not return
@@ -85,7 +85,7 @@ module Sisimai
85
85
  # header such as X-AWS-Outgoing, X-Yandex-Uniq.
86
86
  PatternTable = {
87
87
  'subject' => {
88
- %r/delivery/i => [
88
+ 'delivery' => [
89
89
  'Sisimai::Bite::Email::Exim',
90
90
  'Sisimai::Bite::Email::Courier',
91
91
  'Sisimai::Bite::Email::Google',
@@ -99,7 +99,7 @@ module Sisimai
99
99
  'Sisimai::Bite::Email::X3',
100
100
  'Sisimai::Bite::Email::X2',
101
101
  ],
102
- %r/noti(?:ce|fi)/i => [
102
+ 'noti' => [
103
103
  'Sisimai::Bite::Email::Qmail',
104
104
  'Sisimai::Bite::Email::Sendmail',
105
105
  'Sisimai::Bite::Email::Google',
@@ -111,7 +111,7 @@ module Sisimai
111
111
  'Sisimai::Bite::Email::X3',
112
112
  'Sisimai::Bite::Email::MFILTER',
113
113
  ],
114
- %r/return/i => [
114
+ 'return' => [
115
115
  'Sisimai::Bite::Email::Postfix',
116
116
  'Sisimai::Bite::Email::Sendmail',
117
117
  'Sisimai::Bite::Email::SendGrid',
@@ -121,7 +121,7 @@ module Sisimai
121
121
  'Sisimai::Bite::Email::Biglobe',
122
122
  'Sisimai::Bite::Email::V5sendmail',
123
123
  ],
124
- %r/undeliver/i => [
124
+ 'undeliver' => [
125
125
  'Sisimai::Bite::Email::Postfix',
126
126
  'Sisimai::Bite::Email::Exchange2007',
127
127
  'Sisimai::Bite::Email::Exchange2003',
@@ -132,7 +132,7 @@ module Sisimai
132
132
  'Sisimai::Bite::Email::IMailServer',
133
133
  'Sisimai::Bite::Email::MailMarshalSMTP',
134
134
  ],
135
- %r/failure/i => [
135
+ 'failure' => [
136
136
  'Sisimai::Bite::Email::Qmail',
137
137
  'Sisimai::Bite::Email::Domino',
138
138
  'Sisimai::Bite::Email::Google',
@@ -142,7 +142,7 @@ module Sisimai
142
142
  'Sisimai::Bite::Email::X2',
143
143
  'Sisimai::Bite::Email::MFILTER',
144
144
  ],
145
- %r/warning/i => [
145
+ 'warning' => [
146
146
  'Sisimai::Bite::Email::Postfix',
147
147
  'Sisimai::Bite::Email::Sendmail',
148
148
  'Sisimai::Bite::Email::Exim',
@@ -150,23 +150,10 @@ module Sisimai
150
150
  },
151
151
  }.freeze
152
152
 
153
- make_default_order = lambda do
154
- # Make default order of MTA modules to be loaded
155
- rv = []
156
- begin
157
- rv.concat(Sisimai::Bite::Email.index.map { |e| 'Sisimai::Bite::Email::' << e })
158
- rescue
159
- # Failed to load an MTA module
160
- next
161
- end
162
- return rv
163
- end
164
- DefaultOrder = make_default_order.call
165
-
166
153
  # @abstract Make default order of MTA modules to be loaded
167
154
  # @return [Array] Default order list of MTA modules
168
155
  def default
169
- return DefaultOrder
156
+ return Sisimai::Bite::Email.index.map { |e| 'Sisimai::Bite::Email::' << e }
170
157
  end
171
158
 
172
159
  # @abstract Get regular expression patterns for specified field
@@ -194,18 +181,13 @@ module Sisimai
194
181
  # @abstract Make email header list in each MTA module
195
182
  # @return [Hash] Header list to be parsed
196
183
  def headers
197
- order = self.default
184
+ order = Sisimai::Bite::Email.heads.map { |e| 'Sisimai::Bite::Email::' << e }
198
185
  table = {}
199
186
  skips = { 'return-path' => 1, 'x-mailer' => 1 }
200
187
 
201
188
  order.each do |e|
202
189
  # Load email headers from each MTA module
203
- begin
204
- require e.gsub('::', '/').downcase
205
- rescue LoadError
206
- warn ' ***warning: Failed to load ' << e
207
- next
208
- end
190
+ require e.gsub('::', '/').downcase
209
191
 
210
192
  Module.const_get(e).headerlist.each do |v|
211
193
  # Get header name which required each MTA module
@@ -19,22 +19,16 @@ module Sisimai
19
19
  # true: Matched
20
20
  def match(argv1)
21
21
  return nil unless argv1
22
- regex = %r{(?>
23
- improper[ ]use[ ]of[ ]8-bit[ ]data[ ]in[ ]message[ ]header
24
- |message[ ](?:
25
- header[ ]size,[ ]or[ ]recipient[ ]list,[ ]exceeds[ ]policy[ ]limit
26
- |mime[ ]complexity[ ]exceeds[ ]the[ ]policy[ ]maximum
27
- )
28
- |routing[ ]loop[ ]detected[ ][-][-][ ]too[ ]many[ ]received:[ ]headers
29
- |this[ ]message[ ]contains?[ ](?:
30
- invalid[ ]mime[ ]headers
31
- |improperly[-]formatted[ ]binary[ ]content
32
- |text[ ]that[ ]uses[ ]unnecessary[ ]base64[ ]encoding
33
- )
34
- )
35
- }x
36
-
37
- return true if argv1 =~ regex
22
+ index = [
23
+ 'improper use of 8-bit data in message header',
24
+ 'message header size, or recipient list, exceeds policy limit',
25
+ 'message mime complexity exceeds the policy maximum',
26
+ 'routing loop detected -- too many received: headers',
27
+ 'this message contain invalid mime headers',
28
+ 'this message contain improperly-formatted binary content',
29
+ 'this message contain text that uses unnecessary base64 encoding',
30
+ ]
31
+ return true if index.find { |a| argv1.include?(a) }
38
32
  return false
39
33
  end
40
34