sisimai 4.22.7 → 4.23.0
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.
- checksums.yaml +4 -4
- data/ChangeLog.md +15 -0
- data/README-JA.md +13 -8
- data/README.md +14 -9
- data/lib/sisimai.rb +11 -12
- data/lib/sisimai/address.rb +13 -23
- data/lib/sisimai/arf.rb +10 -12
- data/lib/sisimai/bite/email/activehunter.rb +5 -9
- data/lib/sisimai/bite/email/amazonses.rb +12 -18
- data/lib/sisimai/bite/email/amazonworkmail.rb +7 -12
- data/lib/sisimai/bite/email/aol.rb +10 -16
- data/lib/sisimai/bite/email/apachejames.rb +8 -12
- data/lib/sisimai/bite/email/bigfoot.rb +10 -15
- data/lib/sisimai/bite/email/biglobe.rb +7 -11
- data/lib/sisimai/bite/email/courier.rb +11 -15
- data/lib/sisimai/bite/email/domino.rb +8 -13
- data/lib/sisimai/bite/email/einsundeins.rb +7 -11
- data/lib/sisimai/bite/email/exchange2003.rb +11 -15
- data/lib/sisimai/bite/email/exchange2007.rb +7 -11
- data/lib/sisimai/bite/email/exim.rb +20 -27
- data/lib/sisimai/bite/email/ezweb.rb +13 -22
- data/lib/sisimai/bite/email/facebook.rb +7 -10
- data/lib/sisimai/bite/email/fml.rb +4 -7
- data/lib/sisimai/bite/email/gmx.rb +7 -12
- data/lib/sisimai/bite/email/google.rb +6 -12
- data/lib/sisimai/bite/email/gsuite.rb +11 -18
- data/lib/sisimai/bite/email/imailserver.rb +6 -10
- data/lib/sisimai/bite/email/interscanmss.rb +7 -11
- data/lib/sisimai/bite/email/kddi.rb +10 -16
- data/lib/sisimai/bite/email/mailfoundry.rb +6 -9
- data/lib/sisimai/bite/email/mailmarshalsmtp.rb +6 -10
- data/lib/sisimai/bite/email/mailru.rb +12 -16
- data/lib/sisimai/bite/email/mcafee.rb +5 -9
- data/lib/sisimai/bite/email/messagelabs.rb +7 -10
- data/lib/sisimai/bite/email/messagingserver.rb +8 -14
- data/lib/sisimai/bite/email/mfilter.rb +6 -10
- data/lib/sisimai/bite/email/mxlogic.rb +11 -17
- data/lib/sisimai/bite/email/notes.rb +9 -13
- data/lib/sisimai/bite/email/office365.rb +8 -13
- data/lib/sisimai/bite/email/opensmtpd.rb +7 -11
- data/lib/sisimai/bite/email/outlook.rb +9 -13
- data/lib/sisimai/bite/email/postfix.rb +12 -18
- data/lib/sisimai/bite/email/qmail.rb +10 -15
- data/lib/sisimai/bite/email/receivingses.rb +10 -17
- data/lib/sisimai/bite/email/sendgrid.rb +8 -14
- data/lib/sisimai/bite/email/sendmail.rb +8 -12
- data/lib/sisimai/bite/email/surfcontrol.rb +5 -9
- data/lib/sisimai/bite/email/userdefined.rb +5 -8
- data/lib/sisimai/bite/email/v5sendmail.rb +7 -11
- data/lib/sisimai/bite/email/verizon.rb +14 -28
- data/lib/sisimai/bite/email/x1.rb +5 -8
- data/lib/sisimai/bite/email/x2.rb +5 -8
- data/lib/sisimai/bite/email/x3.rb +5 -9
- data/lib/sisimai/bite/email/x4.rb +10 -14
- data/lib/sisimai/bite/email/x5.rb +6 -11
- data/lib/sisimai/bite/email/yahoo.rb +6 -11
- data/lib/sisimai/bite/email/yandex.rb +8 -12
- data/lib/sisimai/bite/email/zoho.rb +7 -12
- data/lib/sisimai/bite/json/amazonses.rb +6 -12
- data/lib/sisimai/bite/json/sendgrid.rb +1 -7
- data/lib/sisimai/data.rb +26 -34
- data/lib/sisimai/datetime.rb +5 -5
- data/lib/sisimai/mail.rb +9 -3
- data/lib/sisimai/mail/maildir.rb +1 -3
- data/lib/sisimai/mail/mbox.rb +1 -1
- data/lib/sisimai/mail/memory.rb +47 -0
- data/lib/sisimai/mail/stdin.rb +1 -1
- data/lib/sisimai/mda.rb +7 -10
- data/lib/sisimai/message.rb +4 -6
- data/lib/sisimai/message/email.rb +16 -24
- data/lib/sisimai/message/json.rb +3 -5
- data/lib/sisimai/mime.rb +13 -18
- data/lib/sisimai/order/email.rb +5 -8
- data/lib/sisimai/order/json.rb +2 -2
- data/lib/sisimai/reason.rb +3 -7
- data/lib/sisimai/reason/blocked.rb +0 -4
- data/lib/sisimai/reason/contenterror.rb +1 -1
- data/lib/sisimai/reason/exceedlimit.rb +2 -5
- data/lib/sisimai/reason/expired.rb +1 -1
- data/lib/sisimai/reason/filtered.rb +1 -4
- data/lib/sisimai/reason/hasmoved.rb +1 -4
- data/lib/sisimai/reason/hostunknown.rb +1 -4
- data/lib/sisimai/reason/mailboxfull.rb +2 -5
- data/lib/sisimai/reason/mesgtoobig.rb +1 -4
- data/lib/sisimai/reason/networkerror.rb +1 -1
- data/lib/sisimai/reason/norelaying.rb +1 -4
- data/lib/sisimai/reason/notaccept.rb +1 -3
- data/lib/sisimai/reason/onhold.rb +1 -5
- data/lib/sisimai/reason/policyviolation.rb +1 -1
- data/lib/sisimai/reason/rejected.rb +2 -6
- data/lib/sisimai/reason/spamdetected.rb +1 -5
- data/lib/sisimai/reason/suspend.rb +2 -5
- data/lib/sisimai/reason/syntaxerror.rb +0 -3
- data/lib/sisimai/reason/systemerror.rb +1 -1
- data/lib/sisimai/reason/systemfull.rb +1 -1
- data/lib/sisimai/reason/toomanyconn.rb +1 -5
- data/lib/sisimai/reason/userunknown.rb +1 -4
- data/lib/sisimai/reason/vacation.rb +1 -1
- data/lib/sisimai/reason/virusdetected.rb +1 -1
- data/lib/sisimai/rfc2606.rb +3 -3
- data/lib/sisimai/rfc3464.rb +12 -20
- data/lib/sisimai/rfc3834.rb +1 -10
- data/lib/sisimai/rfc5322.rb +4 -6
- data/lib/sisimai/rhost.rb +0 -4
- data/lib/sisimai/rhost/exchangeonline.rb +5 -7
- data/lib/sisimai/rhost/franceptt.rb +1 -3
- data/lib/sisimai/rhost/godaddy.rb +2 -4
- data/lib/sisimai/rhost/googleapps.rb +2 -4
- data/lib/sisimai/rhost/kddi.rb +0 -3
- data/lib/sisimai/smtp/error.rb +0 -3
- data/lib/sisimai/smtp/reply.rb +5 -8
- data/lib/sisimai/smtp/status.rb +3 -4
- data/lib/sisimai/string.rb +13 -20
- data/lib/sisimai/version.rb +1 -1
- data/set-of-emails/maildir/bsd/email-office365-09.eml +596 -0
- data/set-of-emails/maildir/bsd/email-office365-10.eml +594 -0
- data/set-of-emails/maildir/bsd/email-postfix-45.eml +76 -0
- metadata +6 -2
@@ -153,11 +153,8 @@ module Sisimai
|
|
153
153
|
# false: is not unknown user.
|
154
154
|
# @see http://www.ietf.org/rfc/rfc2822.txt
|
155
155
|
def true(argvs)
|
156
|
-
return nil unless argvs
|
157
|
-
return nil unless argvs.is_a? Sisimai::Data
|
158
156
|
return true if argvs.reason == 'userunknown'
|
159
157
|
|
160
|
-
require 'sisimai/smtp/status'
|
161
158
|
diagnostic = argvs.diagnosticcode.downcase;
|
162
159
|
tempreason = Sisimai::SMTP::Status.name(argvs.deliverystatus)
|
163
160
|
return false if tempreason == 'suspend'
|
@@ -170,7 +167,7 @@ module Sisimai
|
|
170
167
|
prematches = %w[NoRelaying Blocked MailboxFull HasMoved Blocked Rejected]
|
171
168
|
matchother = false
|
172
169
|
|
173
|
-
prematches.
|
170
|
+
while e = prematches.shift do
|
174
171
|
# Check the value of "Diagnostic-Code" with other error patterns.
|
175
172
|
p = 'Sisimai::Reason::' << e
|
176
173
|
r = nil
|
data/lib/sisimai/rfc2606.rb
CHANGED
@@ -13,9 +13,9 @@ module Sisimai
|
|
13
13
|
return false unless argv
|
14
14
|
return false unless argv.is_a?(::String)
|
15
15
|
|
16
|
-
return true
|
17
|
-
return true
|
18
|
-
return true
|
16
|
+
return true if argv =~ /[.](?:test|example|invalid|localhost)\z/
|
17
|
+
return true if argv =~ /example[.](?:com|net|org|jp)\z/
|
18
|
+
return true if argv =~ /example[.](?:ac|ad|co|ed|go|gr|lg|ne|or)[.]jp\z/
|
19
19
|
return false
|
20
20
|
end
|
21
21
|
end
|
data/lib/sisimai/rfc3464.rb
CHANGED
@@ -43,13 +43,7 @@ module Sisimai
|
|
43
43
|
# @return [Hash, Nil] Bounce data list and message/rfc822 part
|
44
44
|
# or nil if it failed to parse or the
|
45
45
|
def scan(mhead, mbody)
|
46
|
-
return nil unless mhead
|
47
|
-
return nil unless mbody
|
48
|
-
return nil if mhead.keys.size.zero?
|
49
|
-
return nil if mbody.empty?
|
50
|
-
|
51
46
|
require 'sisimai/mda'
|
52
|
-
require 'sisimai/address'
|
53
47
|
|
54
48
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
55
49
|
hasdivided = mbody.scrub('?').split("\n")
|
@@ -72,7 +66,7 @@ module Sisimai
|
|
72
66
|
d = e.downcase
|
73
67
|
p = havepassed[-2]
|
74
68
|
|
75
|
-
if readcursor
|
69
|
+
if readcursor == 0
|
76
70
|
# Beginning of the bounce message or delivery status part
|
77
71
|
if d =~ MarkingsOf[:message]
|
78
72
|
readcursor |= Indicators[:deliverystatus]
|
@@ -80,7 +74,7 @@ module Sisimai
|
|
80
74
|
end
|
81
75
|
end
|
82
76
|
|
83
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
77
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
84
78
|
# Beginning of the original message part
|
85
79
|
if d =~ MarkingsOf[:rfc822]
|
86
80
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -99,7 +93,7 @@ module Sisimai
|
|
99
93
|
else
|
100
94
|
# Before "message/rfc822"
|
101
95
|
next unless readcursor & Indicators[:deliverystatus] > 0
|
102
|
-
next
|
96
|
+
next if e.empty?
|
103
97
|
|
104
98
|
v = dscontents[-1]
|
105
99
|
if cv = e.match(/\A(?:Final|Original)-Recipient:[ ]*(?:RFC|rfc)822;[ ]*([^ ]+)\z/) ||
|
@@ -125,7 +119,7 @@ module Sisimai
|
|
125
119
|
x = v['recipienet'] || ''
|
126
120
|
y = Sisimai::Address.s3s4(cv[1])
|
127
121
|
|
128
|
-
if x.
|
122
|
+
if !x.empty? && x != y
|
129
123
|
# There are multiple recipient addresses in the message body.
|
130
124
|
dscontents << Sisimai::Bite.DELIVERYSTATUS
|
131
125
|
v = dscontents[-1]
|
@@ -384,7 +378,7 @@ module Sisimai
|
|
384
378
|
break if d =~ MarkingsOf[:rfc822]
|
385
379
|
break if d =~ re_stop
|
386
380
|
|
387
|
-
next if e.
|
381
|
+
next if e.empty?
|
388
382
|
next if d =~ re_skip
|
389
383
|
next if e.start_with?('*')
|
390
384
|
|
@@ -394,7 +388,7 @@ module Sisimai
|
|
394
388
|
y = Sisimai::Address.s3s4(cv[1])
|
395
389
|
next unless Sisimai::RFC5322.is_emailaddress(y)
|
396
390
|
|
397
|
-
if x.
|
391
|
+
if !x.empty? && x != y
|
398
392
|
# There are multiple recipient addresses in the message body.
|
399
393
|
dscontents << Sisimai::Bite.DELIVERYSTATUS
|
400
394
|
b = dscontents[-1]
|
@@ -414,7 +408,7 @@ module Sisimai
|
|
414
408
|
break
|
415
409
|
end
|
416
410
|
|
417
|
-
|
411
|
+
unless recipients > 0
|
418
412
|
# Try to get a recipient address from email headers
|
419
413
|
rfc822list.each do |e|
|
420
414
|
# Check To: header in the original message
|
@@ -429,20 +423,18 @@ module Sisimai
|
|
429
423
|
recipients += 1
|
430
424
|
end
|
431
425
|
end
|
432
|
-
return nil
|
426
|
+
return nil unless recipients > 0
|
433
427
|
|
434
|
-
|
435
|
-
require 'sisimai/smtp/status'
|
436
|
-
dscontents.map do |e|
|
428
|
+
dscontents.each do |e|
|
437
429
|
# Set default values if each value is empty.
|
438
430
|
connheader.each_key { |a| e[a] ||= connheader[a] || '' }
|
439
431
|
|
440
|
-
if e.key?('alterrors') && e['alterrors'].
|
432
|
+
if e.key?('alterrors') && !e['alterrors'].empty?
|
441
433
|
# Copy alternative error message
|
442
434
|
e['diagnosis'] ||= e['alterrors']
|
443
435
|
if e['diagnosis'].start_with?('-') || e['diagnosis'].end_with?('__')
|
444
436
|
# Override the value of diagnostic code message
|
445
|
-
e['diagnosis'] = e['alterrors']
|
437
|
+
e['diagnosis'] = e['alterrors'] unless e['alterrors'].empty?
|
446
438
|
end
|
447
439
|
e.delete('alterrors')
|
448
440
|
end
|
@@ -452,7 +444,7 @@ module Sisimai
|
|
452
444
|
# Make bounce data by the values returned from Sisimai::MDA->scan()
|
453
445
|
e['agent'] = scannedset['mda'] || self.smtpagent
|
454
446
|
e['reason'] = scannedset['reason'] || 'undefined'
|
455
|
-
e['diagnosis'] = scannedset['message']
|
447
|
+
e['diagnosis'] = scannedset['message'] unless scannedset['message'].empty?
|
456
448
|
e['command'] = ''
|
457
449
|
else
|
458
450
|
# Set the value of smtpagent
|
data/lib/sisimai/rfc3834.rb
CHANGED
@@ -53,11 +53,6 @@ module Sisimai
|
|
53
53
|
# or nil if it failed to parse or the
|
54
54
|
# arguments are missing
|
55
55
|
def scan(mhead, mbody)
|
56
|
-
return nil unless mhead
|
57
|
-
return nil unless mbody
|
58
|
-
return nil if mhead.keys.size.zero?
|
59
|
-
return nil if mbody.size.zero?
|
60
|
-
|
61
56
|
leave = 0
|
62
57
|
match = 0
|
63
58
|
|
@@ -84,7 +79,6 @@ module Sisimai
|
|
84
79
|
return nil if match < 1
|
85
80
|
|
86
81
|
require 'sisimai/bite/email'
|
87
|
-
require 'sisimai/address'
|
88
82
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
89
83
|
hasdivided = mbody.scrub('?').split("\n")
|
90
84
|
rfc822part = '' # (String) message/rfc822-headers part
|
@@ -114,7 +108,6 @@ module Sisimai
|
|
114
108
|
if mhead['content-type']
|
115
109
|
# Get the boundary string and set regular expression for matching with
|
116
110
|
# the boundary string.
|
117
|
-
require 'sisimai/mime'
|
118
111
|
b0 = Sisimai::MIME.boundary(mhead['content-type'], 0)
|
119
112
|
MarkingsOf[:boundary] = %r/\A\Q#{b0}\E\z/ unless b0.empty?
|
120
113
|
end
|
@@ -124,7 +117,7 @@ module Sisimai
|
|
124
117
|
# Read the first 5 lines except a blank line
|
125
118
|
countuntil += 1 if e =~ MarkingsOf[:boundary]
|
126
119
|
|
127
|
-
|
120
|
+
if e.empty?
|
128
121
|
# Check a blank line
|
129
122
|
blanklines += 1
|
130
123
|
break if blanklines > countuntil
|
@@ -140,8 +133,6 @@ module Sisimai
|
|
140
133
|
break if haveloaded >= maxmsgline
|
141
134
|
end
|
142
135
|
v['diagnosis'] ||= mhead['subject']
|
143
|
-
|
144
|
-
require 'sisimai/string'
|
145
136
|
v['diagnosis'] = Sisimai::String.sweep(v['diagnosis'])
|
146
137
|
v['reason'] = 'vacation'
|
147
138
|
v['agent'] = self.smtpagent
|
data/lib/sisimai/rfc5322.rb
CHANGED
@@ -46,9 +46,7 @@ module Sisimai
|
|
46
46
|
# called from Sisimai::Bite::Email::*
|
47
47
|
fv = {}
|
48
48
|
HeaderTable.each_value do |e|
|
49
|
-
e.each
|
50
|
-
fv[ee.downcase] = 1
|
51
|
-
end
|
49
|
+
e.each { |ee| fv[ee.downcase] = 1 }
|
52
50
|
end
|
53
51
|
return fv
|
54
52
|
end
|
@@ -60,7 +58,7 @@ module Sisimai
|
|
60
58
|
# @param [Symbol] group RFC822 Header group name
|
61
59
|
# @return [Array,Hash] RFC822 Header list
|
62
60
|
def HEADERFIELDS(group = '')
|
63
|
-
return HeaderIndex
|
61
|
+
return HeaderIndex if group.empty?
|
64
62
|
return HeaderTable[group] if HeaderTable.key?(group)
|
65
63
|
return HeaderTable
|
66
64
|
end
|
@@ -171,7 +169,7 @@ module Sisimai
|
|
171
169
|
break
|
172
170
|
end
|
173
171
|
|
174
|
-
if hostname.
|
172
|
+
if hostname.empty?
|
175
173
|
# 2. Use IP address as a remote host name
|
176
174
|
addrlist.each do |e|
|
177
175
|
# Skip if the address is a private address
|
@@ -187,7 +185,7 @@ module Sisimai
|
|
187
185
|
|
188
186
|
%w[from by].each do |e|
|
189
187
|
# Copy entries into hosts
|
190
|
-
next
|
188
|
+
next if value[e].empty?
|
191
189
|
value[e] = value[e].delete('[]();?')
|
192
190
|
hosts << value[e]
|
193
191
|
end
|
data/lib/sisimai/rhost.rb
CHANGED
@@ -29,7 +29,6 @@ module Sisimai
|
|
29
29
|
# @return [True,False] True: matched
|
30
30
|
# False: did not match
|
31
31
|
def match(rhost)
|
32
|
-
return false unless rhost.is_a? ::String
|
33
32
|
return false if rhost.empty?
|
34
33
|
|
35
34
|
host0 = rhost.downcase
|
@@ -48,9 +47,6 @@ module Sisimai
|
|
48
47
|
# @param [Sisimai::Data] argvs Parsed email object
|
49
48
|
# @return [String] The value of bounce reason
|
50
49
|
def get(argvs)
|
51
|
-
return nil unless argvs
|
52
|
-
return nil unless argvs.is_a? Sisimai::Data
|
53
|
-
|
54
50
|
remotehost = argvs.rhost.downcase
|
55
51
|
rhostclass = ''
|
56
52
|
modulename = ''
|
@@ -111,9 +111,7 @@ module Sisimai
|
|
111
111
|
# @param [Sisimai::Data] argvs Parsed email object
|
112
112
|
# @return [String] The bounce reason for Exchange Online
|
113
113
|
def get(argvs)
|
114
|
-
return
|
115
|
-
return nil unless argvs.is_a? Sisimai::Data
|
116
|
-
return argvs.reason if argvs.reason.size > 0
|
114
|
+
return argvs.reason unless argvs.reason.empty?
|
117
115
|
|
118
116
|
statuscode = argvs.deliverystatus
|
119
117
|
statusmesg = argvs.diagnosticcode
|
@@ -128,7 +126,7 @@ module Sisimai
|
|
128
126
|
reasontext = f[:reason]
|
129
127
|
break
|
130
128
|
end
|
131
|
-
break
|
129
|
+
break unless reasontext.empty?
|
132
130
|
end
|
133
131
|
|
134
132
|
if reasontext.empty?
|
@@ -142,9 +140,9 @@ module Sisimai
|
|
142
140
|
reasontext = f[:reason]
|
143
141
|
break
|
144
142
|
end
|
145
|
-
break
|
143
|
+
break unless reasontext.empty?
|
146
144
|
end
|
147
|
-
break
|
145
|
+
break unless reasontext.empty?
|
148
146
|
end
|
149
147
|
|
150
148
|
if reasontext.empty?
|
@@ -157,7 +155,7 @@ module Sisimai
|
|
157
155
|
reasontext = e.to_s
|
158
156
|
break
|
159
157
|
end
|
160
|
-
break
|
158
|
+
break unless reasontext.empty?
|
161
159
|
end
|
162
160
|
end
|
163
161
|
end
|
@@ -36,9 +36,7 @@ module Sisimai
|
|
36
36
|
# @param [Sisimai::Data] argvs Parsed email object
|
37
37
|
# @return [String] The bounce reason for Orange or La Poste
|
38
38
|
def get(argvs)
|
39
|
-
return
|
40
|
-
return nil unless argvs.is_a? Sisimai::Data
|
41
|
-
return argvs.reason if argvs.reason.size > 0
|
39
|
+
return argvs.reason unless argvs.reason.empty?
|
42
40
|
|
43
41
|
statusmesg = argvs.diagnosticcode
|
44
42
|
reasontext = ''
|
@@ -43,9 +43,7 @@ module Sisimai
|
|
43
43
|
# @return [String] The bounce reason for GoDaddy
|
44
44
|
# @see https://www.godaddy.com/help/what-does-my-email-bounceback-mean-3568
|
45
45
|
def get(argvs)
|
46
|
-
return
|
47
|
-
return nil unless argvs.is_a? Sisimai::Data
|
48
|
-
return argvs.reason if argvs.reason.size > 0
|
46
|
+
return argvs.reason unless argvs.reason.empty?
|
49
47
|
|
50
48
|
statusmesg = argvs.diagnosticcode
|
51
49
|
reasontext = ''
|
@@ -61,7 +59,7 @@ module Sisimai
|
|
61
59
|
reasontext = e.to_s
|
62
60
|
break
|
63
61
|
end
|
64
|
-
break
|
62
|
+
break unless reasontext.empty?
|
65
63
|
end
|
66
64
|
end
|
67
65
|
return reasontext
|
@@ -111,9 +111,7 @@ module Sisimai
|
|
111
111
|
# @return [String] The bounce reason for Google Apps
|
112
112
|
# @see https://support.google.com/a/answer/3726730?hl=en
|
113
113
|
def get(argvs)
|
114
|
-
return
|
115
|
-
return nil unless argvs.is_a? Sisimai::Data
|
116
|
-
return argvs.reason if argvs.reason.size > 0
|
114
|
+
return argvs.reason unless argvs.reason.empty?
|
117
115
|
|
118
116
|
reasontext = ''
|
119
117
|
statuscode = argvs.deliverystatus.clone
|
@@ -123,7 +121,7 @@ module Sisimai
|
|
123
121
|
|
124
122
|
StatusList[statuscode.to_sym].each do |e|
|
125
123
|
# Try to match
|
126
|
-
next unless e[:regexp].
|
124
|
+
next unless e[:regexp].any? { |a| argvs.diagnosticcode.include?(a) }
|
127
125
|
reasontext = e[:reason]
|
128
126
|
break
|
129
127
|
end
|
data/lib/sisimai/rhost/kddi.rb
CHANGED
@@ -16,9 +16,6 @@ module Sisimai
|
|
16
16
|
# @param [Sisimai::Data] argvs Parsed email object
|
17
17
|
# @return [String] The bounce reason for au.com or ezweb.ne.jp
|
18
18
|
def get(argvs)
|
19
|
-
return nil unless argvs
|
20
|
-
return nil unless argvs.is_a? Sisimai::Data
|
21
|
-
|
22
19
|
statusmesg = argvs.diagnosticcode
|
23
20
|
reasontext = ''
|
24
21
|
|
data/lib/sisimai/smtp/error.rb
CHANGED
@@ -24,9 +24,6 @@ module Sisimai
|
|
24
24
|
# nil: is not an error
|
25
25
|
# @since v4.17.3
|
26
26
|
def is_permanent(argv1 = '')
|
27
|
-
return nil unless argv1
|
28
|
-
return nil unless argv1.size > 0
|
29
|
-
|
30
27
|
getchecked = nil
|
31
28
|
statuscode = Sisimai::SMTP::Status.find(argv1)
|
32
29
|
statuscode = Sisimai::SMTP::Reply.find(argv1) if statuscode.empty?
|
data/lib/sisimai/smtp/reply.rb
CHANGED
@@ -67,22 +67,19 @@ module Sisimai
|
|
67
67
|
# did not include SMTP Reply Code value
|
68
68
|
def find(argv1 = '')
|
69
69
|
return '' unless argv1
|
70
|
-
return ''
|
70
|
+
return '' if argv1.empty?
|
71
71
|
return '' if argv1.upcase.include?('X-UNIX')
|
72
72
|
|
73
|
+
# Convert found IPv4 addresses to '***.***.***.***' to avoid that
|
74
|
+
# the following code detects an octet of the IPv4 adress as an SMTP
|
75
|
+
# reply code.
|
73
76
|
ip4re = %r{\b
|
74
77
|
(?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
|
75
78
|
(?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
|
76
79
|
(?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
|
77
80
|
(?:\d|[01]?\d\d|2[0-4]\d|25[0-5])
|
78
81
|
\b}x
|
79
|
-
|
80
|
-
if argv1 =~ ip4re
|
81
|
-
# Convert found IPv4 addresses to '***.***.***.***' to avoid that
|
82
|
-
# the following code detects an octet of the IPv4 adress as an SMTP
|
83
|
-
# reply code.
|
84
|
-
argv1 = argv1.gsub(/#{ip4re}/, '***.***.***.***')
|
85
|
-
end
|
82
|
+
argv1 = argv1.gsub(/#{ip4re}/, '***.***.***.***') if argv1 =~ ip4re
|
86
83
|
|
87
84
|
if cv = argv1.match(/\b([45][0-5][0-9])\b/) || argv1.match(/\b(25[0-3])\b/)
|
88
85
|
# 550, 447, or 250
|
data/lib/sisimai/smtp/status.rb
CHANGED
@@ -712,7 +712,7 @@ module Sisimai
|
|
712
712
|
# @see name
|
713
713
|
def code(argv1 = '', argv2 = false)
|
714
714
|
return '' unless argv1
|
715
|
-
return ''
|
715
|
+
return '' if argv1.empty?
|
716
716
|
|
717
717
|
table = argv2 ? InternalCode[:temporary] : InternalCode[:permanent]
|
718
718
|
code0 = table[argv1.to_sym] || InternalCode[:permanent][argv1.to_sym] || ''
|
@@ -726,7 +726,6 @@ module Sisimai
|
|
726
726
|
# @see code
|
727
727
|
def name(argv1 = '')
|
728
728
|
return '' unless argv1
|
729
|
-
return '' unless argv1.size > 0
|
730
729
|
return '' unless argv1 =~ /\A[245][.]\d[.]\d+\z/
|
731
730
|
return StandardCode[argv1.to_sym] || ''
|
732
731
|
end
|
@@ -737,7 +736,7 @@ module Sisimai
|
|
737
736
|
# not include DSN
|
738
737
|
def find(argv1 = '')
|
739
738
|
return '' unless argv1
|
740
|
-
return ''
|
739
|
+
return '' if argv1.empty?
|
741
740
|
|
742
741
|
foundvalue = ''
|
743
742
|
regularexp = [
|
@@ -747,7 +746,7 @@ module Sisimai
|
|
747
746
|
%r/\b(2[.][0-7][.][0-7])\b/, # 2.1.5
|
748
747
|
]
|
749
748
|
|
750
|
-
regularexp.
|
749
|
+
while e = regularexp.shift do
|
751
750
|
# Get the value of D.S.N. in the text
|
752
751
|
next unless r = argv1.match(e)
|
753
752
|
foundvalue = r[1]
|
data/lib/sisimai/string.rb
CHANGED
@@ -17,10 +17,10 @@ module Sisimai
|
|
17
17
|
# @see http://en.wikipedia.org/wiki/ASCII
|
18
18
|
def token(addr1, addr2, epoch)
|
19
19
|
return '' unless addr1.is_a?(::String)
|
20
|
-
return '' unless addr1.length > 0
|
21
20
|
return '' unless addr2.is_a?(::String)
|
22
|
-
return '' unless addr2.length > 0
|
23
21
|
return '' unless epoch.is_a?(Integer)
|
22
|
+
return '' if addr1.empty?
|
23
|
+
return '' if addr2.empty?
|
24
24
|
|
25
25
|
# Format: STX(0x02) Sender-Address RS(0x1e) Recipient-Address ETX(0x03)
|
26
26
|
require 'digest/sha1'
|
@@ -47,12 +47,8 @@ module Sisimai
|
|
47
47
|
# sweep(' neko ') #=> 'neko'
|
48
48
|
def sweep(argv1)
|
49
49
|
return argv1 unless argv1.is_a?(::String)
|
50
|
-
|
51
|
-
argv1
|
52
|
-
argv1 = argv1.squeeze(' ')
|
53
|
-
argv1 = argv1.delete("\t")
|
54
|
-
argv1 = argv1.strip
|
55
|
-
argv1 = argv1.sub(/ [-]{2,}[^ \t].+\z/, '')
|
50
|
+
argv1 = argv1.chomp.squeeze(' ').delete("\t").strip
|
51
|
+
argv1.sub!(/ [-]{2,}[^ \t].+\z/, '')
|
56
52
|
|
57
53
|
return argv1
|
58
54
|
end
|
@@ -75,17 +71,14 @@ module Sisimai
|
|
75
71
|
# Rewrite <a> elements
|
76
72
|
# 1. <a href = 'http://...'>...</a> to " http://... "
|
77
73
|
# 2. <a href = 'mailto:...'>...</a> to " Value <mailto:...> "
|
78
|
-
plain
|
79
|
-
plain
|
80
|
-
plain
|
81
|
-
|
82
|
-
plain = plain.gsub(/<[^<@>]+?>\s*/, ' ')
|
83
|
-
plain = plain.gsub(/</, '<')
|
84
|
-
plain = plain.gsub(/&
|
85
|
-
plain = plain.gsub(/&
|
86
|
-
plain = plain.gsub(/"/, '"') # Convert to '"'
|
87
|
-
plain = plain.gsub(/'/, "'") # Convert to "'"
|
88
|
-
plain = plain.gsub(/ /, ' ') # Convert to ' '
|
74
|
+
plain.scrub!('?')
|
75
|
+
plain.gsub!(%r|<a\s+href\s*=\s*['"](https?://.+?)['"].*?>(.*?)</a>|i, '[\2](\1)')
|
76
|
+
plain.gsub!(%r|<a\s+href\s*=\s*["']mailto:([^\s]+?)["']>(.*?)</a>|i, '[\2](mailto:\1)')
|
77
|
+
|
78
|
+
plain = plain.gsub(/<[^<@>]+?>\s*/, ' ') # Delete HTML tags except <neko@example.jp>
|
79
|
+
plain = plain.gsub(/</, '<').gsub(/>/, '>') # Convert to angle brackets
|
80
|
+
plain = plain.gsub(/&/, '&').gsub(/ /, ' ') # Convert to "&"
|
81
|
+
plain = plain.gsub(/"/, '"').gsub(/'/, "'") # Convert to " and '
|
89
82
|
|
90
83
|
if argv1.size > plain.size
|
91
84
|
plain = plain.squeeze(' ')
|
@@ -101,7 +94,7 @@ module Sisimai
|
|
101
94
|
# @param [String] argv2 Encoding name before converting
|
102
95
|
# @return [String] UTF-8 Encoded string
|
103
96
|
def to_utf8(argv1 = '', argv2 = nil)
|
104
|
-
return ''
|
97
|
+
return '' if argv1.empty?
|
105
98
|
|
106
99
|
encodefrom = argv2 || false
|
107
100
|
getencoded = ''
|