Skip to content

CRLF before MIME boundary delimiter is incorrectly treated as the body #127

@link2xt

Description

@link2xt

https://www.rfc-editor.org/rfc/rfc2046#section-5.1.1 is clear on how to interpret CRLF before the boundary:
"NOTE: The CRLF preceding the boundary delimiter line is conceptually attached to the boundary so that it is possible to have a part that does not end with a CRLF (line break). Body parts that must be considered to end with line breaks, therefore, must have two CRLFs preceding the boundary delimiter line, the first of which is part of the preceding body part, and the second of which is part of the encapsulation boundary."

It also provides an example:

From: Nathaniel Borenstein <[email protected]>
To: Ned Freed <[email protected]>
Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)
Subject: Sample message
MIME-Version: 1.0
Content-type: multipart/mixed; boundary="simple boundary"

This is the preamble.  It is to be ignored, though it
is a handy place for composition agents to include an
explanatory note to non-MIME conformant readers.

--simple boundary

This is implicitly typed plain US-ASCII text.
It does NOT end with a linebreak.
--simple boundary
Content-type: text/plain; charset=us-ascii

This is explicitly typed plain US-ASCII text.
It DOES end with a linebreak.

--simple boundary--

This is the epilogue.  It is also to be ignored.

However, mailparse interprets CRLF right before the boundary as part of the body. This causes troubles when round-tripping with mail-builder: stalwartlabs/mail-builder#30

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