Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String select function and other improvements #57

Merged
merged 49 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
894fadd
Implement sisimai/string.Select() function
azumakuniyuki Feb 13, 2025
00626f0
#41 Test suites for sisimai/string.Select() 894fadd
azumakuniyuki Feb 13, 2025
7b5f96c
Use sisimai/string.Select() for getting the error code of i.ua 894fadd
azumakuniyuki Feb 13, 2025
b10fcc9
Use sisimai/string.Select() for getting the error code of GoDaddy 894…
azumakuniyuki Feb 13, 2025
50dbae2
Use sisimai/string.Select() for getting the error code of Cox 894fadd
azumakuniyuki Feb 13, 2025
9652029
Use sisimai/string.Select() for getting the value of List-ID: header
azumakuniyuki Feb 13, 2025
61e8f6d
Use sisimai/string.Select() for getting a (comment string) 894fadd
azumakuniyuki Feb 13, 2025
f676dc3
Tiny variable scope improvement
azumakuniyuki Feb 13, 2025
945c3fa
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 13, 2025
8233b3f
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 13, 2025
82c7954
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 13, 2025
3240495
894fadd Use sisimai/string.Select() for getting an error code
azumakuniyuki Feb 13, 2025
0134733
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 13, 2025
3f0303c
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 13, 2025
b358fdf
894fadd Use sisimai/string.Select() for getting diagnostic informatio…
azumakuniyuki Feb 13, 2025
a67cde4
894fadd Use sisimai/string.Select() for getting a date string from th…
azumakuniyuki Feb 13, 2025
84b938e
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 13, 2025
d7b4743
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 13, 2025
e666278
894fadd Use sisimai/string.Select() for checking IPv4 or IPv6 address…
azumakuniyuki Feb 13, 2025
ff8993d
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 14, 2025
a76526c
Tiny variable scope improvement
azumakuniyuki Feb 14, 2025
df0ea66
894fadd Use sisimai/string.Select() for getting the Date: and the Sub…
azumakuniyuki Feb 14, 2025
01e7e20
894fadd Use sisimai/string.Select() for getting a JSON string notifie…
azumakuniyuki Feb 14, 2025
6da435b
894fadd Use sisimai/string.Select() for getting recipient addresses f…
azumakuniyuki Feb 14, 2025
4040052
894fadd Use sisimai/string.Select() for getting a recipient address f…
azumakuniyuki Feb 14, 2025
0a1524f
Tiny variable scope improvement 4040052
azumakuniyuki Feb 14, 2025
e21b6e2
Variable scopes improved
azumakuniyuki Feb 14, 2025
9282b4d
894fadd Use sisimai/string.Select() for getting a remote host address…
azumakuniyuki Feb 15, 2025
720c39a
894fadd Use sisimai/string.Select() for getting an erorr code number …
azumakuniyuki Feb 15, 2025
04e867a
894fadd Use sisimai/string.Select() for getting a comment from Report…
azumakuniyuki Feb 15, 2025
357bbe3
Reduce variables
azumakuniyuki Feb 15, 2025
2064f2c
Code improvement for strings.*
azumakuniyuki Feb 15, 2025
dabcf93
Reduce variables
azumakuniyuki Feb 15, 2025
c656f6a
Condition block improvement
azumakuniyuki Feb 15, 2025
c37a576
Reduce variables
azumakuniyuki Feb 15, 2025
e7266ab
Fix the comment for sisimai/address.Rise() function
azumakuniyuki Feb 15, 2025
35aba8c
Variable scope improvement
azumakuniyuki Feb 15, 2025
0496e84
Loop and variable scope improvement
azumakuniyuki Feb 15, 2025
0f82663
Use strings.Replace() in the loop
azumakuniyuki Feb 15, 2025
b38191f
Loop and variable scope improvements in lhost/via-*.go
azumakuniyuki Feb 15, 2025
a4b9b5b
Loop and variable scope improvements in message/
azumakuniyuki Feb 15, 2025
8927e8c
Use if {} instead of for {}
azumakuniyuki Feb 15, 2025
bd4a628
if conditions improvement
azumakuniyuki Feb 15, 2025
042775b
Variable scope improvement
azumakuniyuki Feb 15, 2025
08d8602
Remove for{} loop, return as soon as possible in rfc2045.IsEncoded()
azumakuniyuki Feb 15, 2025
f35091e
Variables improvement in rfc2045.DecodeH()
azumakuniyuki Feb 15, 2025
8207868
Immediately return when the argument is empty at rfc2045.DecodeH()
azumakuniyuki Feb 15, 2025
431bbd3
Variable names, scopes, and loop blocks improved
azumakuniyuki Feb 15, 2025
a9bfb2f
Variable names, scopes, and other code improvements
azumakuniyuki Feb 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions address/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func ExpandAlias(email string) string {
if rfc5322.IsQuotedAddress(email) == true { return "" } // Do not expand "neko+cat"@example.org

// neko+straycat@example.org => neko@example.org
lpart := email[0:strings.Index(email, "+")]
dpart := strings.SplitN(email, "@", 2)[1]
return lpart + "@" + dpart
return email[0:strings.Index(email, "+")] + "@" + strings.SplitN(email, "@", 2)[1]
}

8 changes: 2 additions & 6 deletions address/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@
// Try to use the string like an email address in the display name
for _, e := range strings.Split(readbuffer[1], " ") {
// Find an email address
if rfc5322.IsEmailAddress(e) == false { continue }
readbuffer[0] = e; break
if rfc5322.IsEmailAddress(e) { readbuffer[0] = e; break }
}
} else if IsMailerDaemon(readbuffer[1]) == true {
// Allow if the string is MAILER-DAEMON
Expand All @@ -230,10 +229,7 @@
// - (cat)nekochan@example.org
// - nekochan(cat)cat@example.org
// - nekochan(cat)@example.org
p1 := strings.Index(readbuffer[0], "(")
p2 := strings.Index(readbuffer[0], ")")
ce := readbuffer[0][p1:p2 + 1]

ce := "(" + sisimoji.Select(readbuffer[0], "(", ")", 0) + ")"

Check warning on line 232 in address/find.go

View check run for this annotation

Codecov / codecov/patch

address/find.go#L232

Added line #L232 was not covered by tests
readbuffer[0] = strings.Replace(readbuffer[0], ce, "", 1)
if len(readbuffer[2]) == 0 { readbuffer[2] = ce } else { readbuffer[2] += " " + ce }
}
Expand Down
5 changes: 2 additions & 3 deletions address/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func IsIncluded(argv0 string) bool {
// Such as "nekochan (kijitora) neko@example.jp"
for _, e := range strings.Split(argv0, " ") {
// Is there any email address string in each element?
e = strings.Trim(e, "<>"); if rfc5322.IsEmailAddress(e) { return true }
if rfc5322.IsEmailAddress(strings.Trim(e, "<>")) { return true }
}
}
return false
Expand All @@ -71,7 +71,6 @@ func IsMailerDaemon(email string) bool {
// @param string email Email address
// @return bool true: is a mailer-daemon
// false: is not a mailer-daemon
match := false
value := strings.ToLower(email)
table := []string{
"mailer-daemon@", "(mailer-daemon)", "<mailer-daemon>", "mailer-daemon ",
Expand All @@ -80,5 +79,5 @@ func IsMailerDaemon(email string) bool {
for _, e := range table {
if strings.Contains(value, e) || value == "mailer-daemon" || value == "postmaster" { return true }
}
return match
return false
}
2 changes: 1 addition & 1 deletion address/rise.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package address
import "strings"
import "libsisimai.org/sisimai/sis"

// Rise() is a constructor of Sisimai::Address
// Rise() is a constructor of sis.EmailAddress
func Rise(argvs [3]string) sis.EmailAddress {
// @param [3]string argvs ["Email address", "name", "comment"]
// @return sis.EmailAddress EmailAddress struct when the email address was not valid
Expand Down
7 changes: 2 additions & 5 deletions arf/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@
} else if strings.HasPrefix(e, "Reporting-MTA: ") {
// The header is optional and MUST NOT appear more than once.
// Reporting-MTA: dns; mx.example.jp
cv := rfc1894.Field(e); if len(cv) == 0 { continue }
reportedby = cv[2]
if cv := rfc1894.Field(e); len(cv) > 0 { reportedby = cv[2] }

Check warning on line 185 in arf/lib.go

View check run for this annotation

Codecov / codecov/patch

arf/lib.go#L185

Added line #L185 was not covered by tests

} else if strings.HasPrefix(e, "Source-IP: ") {
// The header is optional and MUST NOT appear more than once.
Expand Down Expand Up @@ -216,9 +215,7 @@

} else {
// Pick it from the original message part
p1 := strings.Index(emailparts[1], "\nTo:"); if p1 < 0 { break }
p2 := sisimoji.IndexOnTheWay(emailparts[1], "\n", p1 + 4); if p2 < 0 { break }
cv := sisiaddr.S3S4(emailparts[1][p1 + 4:p2])
cv := sisiaddr.S3S4(sisimoji.Select(emailparts[1], "\nTo:", "\n", 0))

Check warning on line 218 in arf/lib.go

View check run for this annotation

Codecov / codecov/patch

arf/lib.go#L218

Added line #L218 was not covered by tests

// There is no valid email address in the To: header of the original message such as
// To: <Undisclosed Recipients>
Expand Down
33 changes: 12 additions & 21 deletions fact/rise.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
}
for _, v := range datevalues {
// Parse each date string using net/mail.ParseDate()
times, nyaan := mail.ParseDate(v); if nyaan != nil { continue }
clock = times; break
if times, nyaan := mail.ParseDate(v); nyaan == nil { clock = times; break }
}
if clock.IsZero() {
// Failed to parse the date string at the previous loop,
Expand All @@ -113,8 +112,7 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
// Try to parse the date string tidied by rfc5322.Date()
j := rfc5322.Date(v); if j != "" {
// rfc5322.Date() returned a valid date string
times, nyaan := mail.ParseDate(j); if nyaan != nil { continue }
clock = times; break
if times, nyaan := mail.ParseDate(j); nyaan == nil { clock = times; break }
}
}
}
Expand Down Expand Up @@ -146,8 +144,7 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
for li := 0; li < le; li++ {
// Check the Received: headers forwards and get a local hostnaame
cv := rfc5322.Received((*beforefact).Headers["received"][li])
if rfc1123.IsInternetHost(cv[0]) == false { continue }
e.Lhost = cv[0]; break
if rfc1123.IsInternetHost(cv[0]) { e.Lhost = cv[0]; break }
}
}

Expand All @@ -167,8 +164,7 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
for _, w := range ee {
// Get a hostname from the string like "127.0.0.1 x109-20.example.com 192.0.2.20"
// or "mx.sp.example.jp 192.0.2.135"
if rfc791.IsIPv4Address(w) { continue }
*v = w; break
if rfc791.IsIPv4Address(w) == false { *v = w; break }
}
if strings.Index(*v, " ") > 0 { *v = ee[0] }
}
Expand All @@ -191,10 +187,7 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
// Get the value of List-Id header: "List name <list-id@example.org>"
if len(rfc822data["list-id"]) == 0 { break LIST_ID }
if sisimoji.Aligned(rfc822data["list-id"][0], []string{"<", ".", ">"}) == false { break LIST_ID }
p0 := strings.Index(rfc822data["list-id"][0], "<"); if p0 < 0 { break LIST_ID }
p1 := strings.Index(rfc822data["list-id"][0], ">"); if p1 < 0 { break LIST_ID }

piece["listid"] = rfc822data["list-id"][0][p0 + 1:p1]; break LIST_ID
piece["listid"] = sisimoji.Select(rfc822data["list-id"][0], "<", ">", 0); break LIST_ID
}

DIAGNOSTICCODE: for {
Expand Down Expand Up @@ -319,7 +312,7 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
hops := len(recv)
for i := hops - 1; hops >= 0; hops-- {
// Search for the string " for " from the Received: header
if strings.Index(recv[i], " for ") == -1 { continue }
if strings.Index(recv[i], " for ") == -1 { continue }
or := rfc5322.Received(recv[i])

if len(or) == 0 || or[5] == "" { continue }
Expand All @@ -335,7 +328,7 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
REASON: for thing.Reason == "" || RetryIndex[thing.Reason] {
// Decide the reason of the email bounce
// The value of thing.Reason is empty or is needed to check with other values again
re := thing.Reason; if re == "" { re = "undefined" }
re := thing.Reason; if re == "" { re = "undefined" }
or := lda.Find(&thing); if reason.IsExplicit(or) { thing.Reason = or; break REASON }
or = rhost.Find(&thing); if reason.IsExplicit(or) { thing.Reason = or; break REASON }
or = reason.Find(&thing); if reason.IsExplicit(or) { thing.Reason = or; break REASON }
Expand All @@ -352,9 +345,8 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s

} else {
// The Reason is not "delivered", or "feedback", or "vacation"
smtperrors := piece["deliverystatus"] + " " + piece["diagnosticcode"]
if len(smtperrors) < 4 { smtperrors = "" }
thing.HardBounce = failure.IsHardBounce(thing.Reason, smtperrors)
cv := piece["deliverystatus"] + " " + piece["diagnosticcode"]; if len(cv) < 4 { cv = "" }
thing.HardBounce = failure.IsHardBounce(thing.Reason, cv)
}
break HARDBOUNCE
}
Expand All @@ -363,10 +355,9 @@ func Rise(email *string, origin string, args *sis.DecodingArgs) ([]sis.Fact, []s
// Set a pseudo status code
if thing.DeliveryStatus != "" { break DELIVERYSTATUS }

smtperrors := thing.ReplyCode + " " + piece["diagnosticcode"]
if len(smtperrors) < 4 { smtperrors = "" }
permanent0 := failure.IsPermanent(smtperrors)
temporary0 := failure.IsTemporary(smtperrors)
ce := thing.ReplyCode + " " + piece["diagnosticcode"]; if len(ce) < 4 { ce = "" }
permanent0 := failure.IsPermanent(ce)
temporary0 := failure.IsTemporary(ce)
temporary1 := temporary0; if !permanent0 && !temporary0 { temporary1 = false }
thing.DeliveryStatus = status.Code(thing.Reason, temporary1)
break DELIVERYSTATUS
Expand Down
10 changes: 2 additions & 8 deletions lhost/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ func OrderBySubject(title string) []string {
}

// The following order is decided by the first 2 words of Subject: header
title = strings.Replace(title, "[", " ", -1)
title = strings.Replace(title, "]", " ", -1)
title = strings.Replace(title, "_", " ", -1)
for _, e := range []string{"[", "]", "_"} { title = strings.Replace(title, e, " ", -1) }

// Squeeze duplicated space characters
for strings.Contains(title, " ") { title = strings.ReplaceAll(title, " ", " ") }
Expand All @@ -70,11 +68,7 @@ func OrderBySubject(title string) []string {
// Postmaster notify, returned mail, ...
first = strings.Join(words[0:2], "-")
}

first = strings.ReplaceAll(first, `:`, "")
first = strings.ReplaceAll(first, `,`, "")
first = strings.ReplaceAll(first, `*`, "")
first = strings.ReplaceAll(first, `"`, "")
for _, e := range []string{`:`, `,`, `*`, `"`} { first = strings.ReplaceAll(first, e, "") }
return table[first]
}

Expand Down
8 changes: 3 additions & 5 deletions lhost/via-activehunter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
if strings.HasPrefix(e, startingof["message"][0]) { readcursor |= indicators["deliverystatus"] }
continue
}
if readcursor & indicators["deliverystatus"] == 0 { continue }
if e == "" { continue }
if readcursor & indicators["deliverystatus"] == 0 || e == "" { continue }

Check warning on line 43 in lhost/via-activehunter.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-activehunter.go#L43

Added line #L43 was not covered by tests

// ----- The following addresses had permanent fatal errors -----
//
Expand All @@ -63,9 +62,8 @@
// ----- Transcript of session follows -----
// 550 sorry, no mailbox here by that name (#5.1.1 - chkusr)
cr := []rune(e[0:1])
if cr[0] < 48 || cr[0] > 122 { continue } // 48 = '0', 122 = 'z'
if v.Diagnosis != "" { continue }
v.Diagnosis = e
if cr[0] < 48 || cr[0] > 122 { continue } // 48 = '0', 122 = 'z'
if v.Diagnosis == "" { v.Diagnosis = e }

Check warning on line 66 in lhost/via-activehunter.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-activehunter.go#L65-L66

Added lines #L65 - L66 were not covered by tests
}
}
if recipients == 0 { return sis.RisingUnderway{} }
Expand Down
7 changes: 2 additions & 5 deletions lhost/via-amazonses.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
// "TopicArn" : "arn:aws:sns:us-west-2:123456789012:SES-EJ-B",
// "Message" : "{\"notificationType\"...
if strings.Contains(sespayload, "\\") { sespayload = strings.ReplaceAll(sespayload, "\\", "") }
p3 := sisimoji.IndexOnTheWay(sespayload, "{", p2 + 9)
p4 := sisimoji.IndexOnTheWay(sespayload, "\n", p2 + 9)
sespayload = sespayload[p3:p4]
sespayload = "{" + sisimoji.Select(sespayload, "{", "\n", p2 + 9)

Check warning on line 49 in lhost/via-amazonses.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-amazonses.go#L49

Added line #L49 was not covered by tests
sespayload = strings.TrimRight(sespayload, ",")
sespayload = strings.TrimRight(sespayload, `"`)
}
Expand Down Expand Up @@ -288,8 +286,7 @@

for f := range reasonpair {
// Try to find the bounce reason by "bounceSubType"
if reasonpair[f] != (*o).BounceSubType { continue }
v.Reason = f; break
if reasonpair[f] == (*o).BounceSubType { v.Reason = f; break }

Check warning on line 289 in lhost/via-amazonses.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-amazonses.go#L289

Added line #L289 was not covered by tests
}
}
} else if whatnotify == "C" {
Expand Down
5 changes: 2 additions & 3 deletions lhost/via-apachejames.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
for _, e := range bf.Headers["received"] {
// Received: from localhost ([127.0.0.1])
// by mx.example.org (JAMES SMTP Server 2.3.2) with SMTP ID 220...
if strings.Contains(e, "JAMES SMTP Server") == true { proceedsto = true; break ISJAMES }
if strings.Contains(e, "JAMES SMTP Server") == true { proceedsto = true; break ISJAMES }

Check warning on line 32 in lhost/via-apachejames.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-apachejames.go#L32

Added line #L32 was not covered by tests
}
break
}
Expand Down Expand Up @@ -64,8 +64,7 @@
if e != "" { v.Diagnosis += e + " " }
continue
}
if readcursor & indicators["deliverystatus"] == 0 { continue }
if len(e) == 0 { continue }
if readcursor & indicators["deliverystatus"] == 0 || e == "" { continue }

Check warning on line 67 in lhost/via-apachejames.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-apachejames.go#L67

Added line #L67 was not covered by tests

// Message details:
// Subject: Nyaaan
Expand Down
11 changes: 4 additions & 7 deletions lhost/via-biglobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
if strings.HasPrefix(e, startingof["message"][0]) { readcursor |= indicators["deliverystatus"] }
continue
}
if readcursor & indicators["deliverystatus"] == 0 { continue }
if len(e) == 0 { continue }
if readcursor & indicators["deliverystatus"] == 0 || e == "" { continue }

Check warning on line 57 in lhost/via-biglobe.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-biglobe.go#L57

Added line #L57 was not covered by tests

// This is a MIME-encapsulated message.
//
Expand Down Expand Up @@ -85,8 +84,7 @@

} else {
// The boundary string or the error messages
if strings.Contains(e, "--") { continue }
v.Diagnosis += e + " "
if strings.Contains(e, "--") == false { v.Diagnosis += e + " " }

Check warning on line 87 in lhost/via-biglobe.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-biglobe.go#L87

Added line #L87 was not covered by tests
}
}
if recipients == 0 { return sis.RisingUnderway{} }
Expand All @@ -100,13 +98,12 @@
// The key name is a bounce reason name
for _, f := range messagesof[r] {
// Try to find an error message including lower-cased string listed in messagesof
if strings.Contains(e.Diagnosis, f) == false { continue }
e.Reason = r; break FINDREASON
if strings.Contains(e.Diagnosis, f) { e.Reason = r; break FINDREASON }

Check warning on line 101 in lhost/via-biglobe.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-biglobe.go#L101

Added line #L101 was not covered by tests
}
}
}

return sis.RisingUnderway{ Digest: dscontents, RFC822: emailparts[1] }
}
}
}

6 changes: 2 additions & 4 deletions lhost/via-courier.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
if sisimoji.ContainsAny(e, startingof["message"]) { readcursor |= indicators["deliverystatus"] }
continue
}
if readcursor & indicators["deliverystatus"] == 0 { continue }
if len(e) == 0 { continue }
if readcursor & indicators["deliverystatus"] == 0 || e == "" { continue }

Check warning on line 74 in lhost/via-courier.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-courier.go#L74

Added line #L74 was not covered by tests

f := rfc1894.Match(e); if f > 0 {
// "e" matched with any field defined in RFC3464
Expand Down Expand Up @@ -160,8 +159,7 @@
// The key name is a bounce reason name
for _, f := range messagesof[r] {
// Try to find an error message including lower-cased string listed in messagesof
if strings.Contains(e.Diagnosis, f) == false { continue }
e.Reason = r; break FINDREASON
if strings.Contains(e.Diagnosis, f) { e.Reason = r; break FINDREASON }

Check warning on line 162 in lhost/via-courier.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-courier.go#L162

Added line #L162 was not covered by tests
}
}
e.Command = thecommand
Expand Down
7 changes: 2 additions & 5 deletions lhost/via-domino.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
if strings.HasPrefix(e, startingof["message"][0]) { readcursor |= indicators["deliverystatus"] }
continue
}
if readcursor & indicators["deliverystatus"] == 0 { continue }
if len(e) == 0 { continue }
if readcursor & indicators["deliverystatus"] == 0 || e == "" { continue }

Check warning on line 73 in lhost/via-domino.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-domino.go#L73

Added line #L73 was not covered by tests

// Your message
//
Expand Down Expand Up @@ -169,9 +168,7 @@
if e.Reason != "" { break EXCEPTUTF8 }
for _, f := range exceptutf8[r] {
// Try to find an error message including lower-cased string listed in messagesof
if sisimoji.Aligned(e.Diagnosis, f) == false { continue }
e.Reason = r
break EXCEPTUTF8
if sisimoji.Aligned(e.Diagnosis, f) { e.Reason = r; break EXCEPTUTF8 }

Check warning on line 171 in lhost/via-domino.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-domino.go#L171

Added line #L171 was not covered by tests
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions lhost/via-dragonfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
if strings.HasPrefix(e, startingof["message"][0]) { readcursor |= indicators["deliverystatus"] }
continue
}
if readcursor & indicators["deliverystatus"] == 0 { continue }
if len(e) == 0 { continue }
if readcursor & indicators["deliverystatus"] == 0 || e == "" { continue }

Check warning on line 76 in lhost/via-dragonfly.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-dragonfly.go#L76

Added line #L76 was not covered by tests

// This is the DragonFly Mail Agent v0.13 at df.example.jp.
//
Expand Down Expand Up @@ -120,8 +119,7 @@
// The key name is a bounce reason name
for _, f := range messagesof[r] {
// Try to find an error message including lower-cased string listed in messagesof
if strings.Contains(e.Diagnosis, f) == false { continue }
e.Reason = r; break FINDREASON
if strings.Contains(e.Diagnosis, f) { e.Reason = r; break FINDREASON }

Check warning on line 122 in lhost/via-dragonfly.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-dragonfly.go#L122

Added line #L122 was not covered by tests
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions lhost/via-einsundeins.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
if strings.HasPrefix(e, startingof["message"][0]) { readcursor |= indicators["deliverystatus"] }
continue
}
if readcursor & indicators["deliverystatus"] == 0 { continue }
if e == "" { continue }
if readcursor & indicators["deliverystatus"] == 0 || e == "" { continue }

Check warning on line 50 in lhost/via-einsundeins.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-einsundeins.go#L50

Added line #L50 was not covered by tests

// The following address failed:
//
Expand Down Expand Up @@ -117,8 +116,7 @@
// The key name is a bounce reason name
for _, f := range messagesof[r] {
// Try to find an error message including lower-cased string listed in messagesof
if strings.Contains(e.Diagnosis, f) == false { continue }
e.Reason = r; break FINDREASON
if strings.Contains(e.Diagnosis, f) { e.Reason = r; break FINDREASON }

Check warning on line 119 in lhost/via-einsundeins.go

View check run for this annotation

Codecov / codecov/patch

lhost/via-einsundeins.go#L119

Added line #L119 was not covered by tests
}
}
}
Expand Down
Loading