Hi @jhillyerd
Current Wrap() folds long line after whitespace or tab characters, but if a line doesn't contain any whitespace and tab, it doesn't respect the max length, which means it doesn't fold the long line at all.
And unit test TestWrapIdentityLong is wrong too, correct result should be:
// 46 `a` chars in total.
aaaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n aaaa\r\n a\r\n
According to RFC 5322, section 2.2.3, Long Header Fields:
Note: Though structured field bodies are defined in such a way
that folding can take place between many of the lexical tokens
(and even within some of the lexical tokens), folding SHOULD be
limited to placing the CRLF at higher-level syntactic breaks. For
instance, if a field body is defined as comma-separated values, it
is recommended that folding occur after the comma separating the
structured items in preference to other places where the field
could be folded, even if it is allowed elsewhere.
Suggestions:
- Fold after additional chars like
,, ; too.
- Force to fold when it reaches max length.
Hi @jhillyerd
Current
Wrap()folds long line after whitespace or tab characters, but if a line doesn't contain any whitespace and tab, it doesn't respect the max length, which means it doesn't fold the long line at all.enmime/internal/stringutil/wrap.go
Line 20 in 15dab47
And unit test
TestWrapIdentityLongis wrong too, correct result should be:According to RFC 5322, section 2.2.3,
Long Header Fields:Suggestions:
,,;too.