go-message icon indicating copy to clipboard operation
go-message copied to clipboard

Bump line length soft limit to 998 for headers

Open emersion opened this issue 7 years ago • 6 comments

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

emersion avatar Jul 25 '18 20:07 emersion

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 avatar Mar 01 '24 03:03 maileroo

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.

maileroo avatar Mar 02 '24 12:03 maileroo

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

emersion avatar Mar 02 '24 12:03 emersion

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

maileroo avatar Mar 02 '24 12:03 maileroo

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 avatar Mar 02 '24 17:03 emersion

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

emersion avatar Mar 03 '24 20:03 emersion