emersion / go-message

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

Header size limit of 1MB is too restrictive #149

Closed Spiral90210 closed 2 years ago

Spiral90210 commented 2 years ago

There's a limit to the total header size in entity.go introduced in #123 for what seems a similar issue:

const maxHeaderBytes = 1 << 20 // 1 MB

var errHeaderTooBig = errors.New("message: header exceeds maximum size")

Unfortunately, I've hit that limit. RFC5822 2.2.3 (Long Header Fields - I'd link directly but itef is down right now!) says:

The process of moving from this folded multiple-line representation of a header field to its single line representation is called "unfolding". Unfolding is accomplished by simply removing any CRLF that is immediately followed by WSP. Each header field should be treated in its unfolded form for further syntactic and semantic evaluation. An unfolded header field has no length restriction and therefore may be indeterminately long.

Would it be sensible to increase this limit, or perhaps making it configurable in some way, exporting it as a var/via env? Happy to do a PR if the approach could be agreed beforehand. Until recently o365 had a 10MB limit (I think it's now 100, crazy), so I'll suggest that for now.

emersion commented 2 years ago

There is a plan for this in https://github.com/emersion/go-message/issues/124.

Spiral90210 commented 2 years ago

I like that approach.

December 2020 - is it likely to see inclusion any time soon do you know? Want me to make it into to a PR?

emersion commented 2 years ago

Yes, please open a PR if you have time.

Spiral90210 commented 2 years ago

Done - let me know what you think, and thank you for being open to it.