mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
move checking whether a message needs smtputf8 (has utf8 in any of the header sections) to package message
This commit is contained in:
32
main.go
32
main.go
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto"
|
||||
@ -3519,35 +3518,10 @@ func cmdMessageParse(c *cmd) {
|
||||
err = enc.Encode(part)
|
||||
xcheckf(err, "write")
|
||||
|
||||
hasNonASCII := func(r io.Reader) bool {
|
||||
br := bufio.NewReader(r)
|
||||
for {
|
||||
b, err := br.ReadByte()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
xcheckf(err, "read header")
|
||||
if b > 0x7f {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var walk func(p *message.Part) bool
|
||||
walk = func(p *message.Part) bool {
|
||||
if hasNonASCII(p.HeaderReader()) {
|
||||
return true
|
||||
}
|
||||
for _, pp := range p.Parts {
|
||||
if walk(&pp) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if smtputf8 {
|
||||
fmt.Println("message needs smtputf8:", walk(&part))
|
||||
needs, err := part.NeedsSMTPUTF8()
|
||||
xcheckf(err, "checking if message needs smtputf8")
|
||||
fmt.Println("message needs smtputf8:", needs)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user