mirror of
https://github.com/mjl-/mox.git
synced 2025-06-27 21:48:16 +03:00

As required by RFC 2045 (MIME). The 78 byte lines work in practice, except that SpamAssassin has rules that give messages with 78-byte lines spam points. Mentioned by kjetilho on irc.
22 lines
679 B
Go
22 lines
679 B
Go
package message
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// NeedsQuotedPrintable returns whether text, with crlf-separated lines, should be
|
|
// encoded with quoted-printable, based on line lengths and any bare carriage
|
|
// return or bare newline. If not, it can be included as 7bit or 8bit encoding in a
|
|
// new message.
|
|
func NeedsQuotedPrintable(text string) bool {
|
|
// ../rfc/2045:1025
|
|
for _, line := range strings.Split(text, "\r\n") {
|
|
// 78 should be fine too, qp itself has a requirement of 76 bytes on a line, but
|
|
// using qp for anything longer than 76 is safer.
|
|
if len(line) > 76 || strings.Contains(line, "\r") || strings.Contains(line, "\n") {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|