这是indexloc提供的服务,不要输入任何密码
Skip to content

RFC 5322 character use limitation #80

@dvalter

Description

@dvalter

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 \n is 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 foldLine but 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions