-
Notifications
You must be signed in to change notification settings - Fork 122
Closed
Description
RFC 5322 limits use of characters in general (US-ASCII) and for some specific scopes. For example in headers only printable ASCII characters ('!'..'~'), SPACE and HTAB are allowed and \r\n sequence is used for line folding.
It's currently possible to pass some disallowed symbols to go-message. The most noticeably it's a single \n in header values which is treated as a regular symbol or a part of \r\n sequence. As it was discussed in #77, the best way of handling such cases is just failing with an explicit error.
I have a few possible solutions. but I don't feel like any of them is clearly "the best":
- checking whether
\nis a part of the folding sequence; solves only a subproblem, but does not change behavior on externally folded line - Matching strings with a regex (
"[\t -~]*"for headers); probably the most clean, but may be not great in terms of performance - Manually checking strings symbol by symbol, may introduce some possible optimizations like single pass
foldLinebut certainly is not as fancy as the previous one.
I don't know what would be better to implement (or maybe I don't see something else), so I'd like to discuss it here before coding.
Metadata
Metadata
Assignees
Labels
No labels