fix: part boundray and message encoding

This commit is contained in:
theexiile1305 2024-09-29 16:46:30 +02:00
parent 79f22fb722
commit 46cf2ed498
No known key found for this signature in database
GPG key ID: A1BDDE98F2BF6E40
2 changed files with 9 additions and 3 deletions

View file

@ -138,6 +138,10 @@ func (mw *msgWriter) writeMsg(msg *Msg) {
if msg.hasMixed() {
mw.stopMP()
}
if msg.hasSMime() {
mw.stopMP()
}
}
// writeGenHeader writes out all generic headers to the msgWriter
@ -341,7 +345,7 @@ func (mw *msgWriter) writeBody(writeFunc func(io.Writer) (int64, error), encodin
encodedWriter = quotedprintable.NewWriter(&writeBuffer)
} else if encoding == EncodingB64 && !singingWithSMime {
encodedWriter = base64.NewEncoder(base64.StdEncoding, &lineBreaker)
} else if encoding == NoEncoding {
} else if encoding == NoEncoding || singingWithSMime {
_, err = writeFunc(&writeBuffer)
if err != nil {
mw.err = fmt.Errorf("bodyWriter function: %w", err)

View file

@ -105,8 +105,10 @@ func encodeToPEM(msg []byte) (*string, error) {
}
r := arrayBuffer.String()
r = strings.ReplaceAll(r, "-----BEGIN -----\n", "")
r = strings.ReplaceAll(r, "-----END -----\n", "")
r = strings.TrimPrefix(r, "-----BEGIN -----")
r = strings.Trim(r, "\n")
r = strings.TrimSuffix(r, "-----END -----")
r = strings.Trim(r, "\n")
return &r, nil
}