rfc5322: how to fold values without spaces?

258 Views Asked by At

I've already seen answer on similar topic, but rfc5322 says:

Unfolding is accomplished by simply removing any CRLF that is immediately followed by WSP.

this can break source spaceless text by adding into it spaces.

so how to fold values without spaces?

2

There are 2 best solutions below

0
On BEST ANSWER

The modern solution is to use RFC2047 encoding which allows completely arbitrary folding:

=?us-ascii?B?A?=
 =?us-ascii?B?B?=

encodes the single string AB, preserving the lack of spaces.

1
On

The header format does not allow breaking lines without spaces.

Note that there's nothing wrong with sending long lines — the length limit in header lines is 998 characters (Section 2.3), and if you need to send a header that contains more than 998 characters with no intervening spaces, you're probably doing something wrong.