emersion / go-message

✉️ A streaming Go library for the Internet Message Format and mail messages
MIT License
386 stars 111 forks source link

Bump line length soft limit to 998 for headers #24

Open emersion opened 6 years ago

emersion commented 6 years ago

The algorithm mangling long lines is pretty messy. I'd rather not use it when not needed.

See https://tools.ietf.org/html/rfc5322#section-2.1.1

maileroo commented 8 months ago

Not sure why we are also having trouble with this. DKIM seems to be failing when truncating at 1,000 character, but seems to be doing fine at 994.

wc = nopCloser{textwrapper.New(w, "\r\n", 1000)}

maileroo commented 8 months ago

Think it might make more sense to check each individual line to see if its length is beyond 998 (or 1000) characters. Right now, it's introducing line-breaks every 1000 characters even though they are not really required.

emersion commented 7 months ago

Line breaks every 998 characters at most are required by the RFC.

maileroo commented 7 months ago

Line breaks every 998 characters at most are required by the RFC.

Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

Yes, but the textwrapper seems to be doing every 998 characters. So if you've a 2,000 characters long email, it will split into two halves even though it may not be necessary. You only need to add a linebreak if a line is more than 998 characters.

Maybe I understand it incorrectly

emersion commented 7 months ago

Yeah, that's not related to this issue though. I would've sworn that we have another issue tracking this but can't find it anymore...

emersion commented 7 months ago

https://github.com/emersion/go-message/pull/176 should help with the issue you describe.