Treat trailing lines in multipart parts as significant#208
Merged
andrewtimberlake merged 2 commits intoDockYard:masterfrom Dec 4, 2025
Merged
Conversation
tisdall
reviewed
Oct 22, 2025
lib/mail/parsers/rfc_2822.ex
Outdated
Comment on lines
+63
to
+65
| |> String.trim_trailing("\r\n") | ||
| |> String.split("\r\n") | ||
| |> Enum.map(&String.trim_trailing/1) |
Contributor
There was a problem hiding this comment.
I looked at the rest of the PR and it all looks good, but I wasn't sure about this part... Why the additional trimming of trailing CRLF?
This is already in the existing code, but what's the issue with just doing String.split("\r\n") and not trimming the end of each line? Thus keeping all the encoded content.
Contributor
There was a problem hiding this comment.
I see the 2nd trim_trailing is related to a test case (test "parse invalid date in Received header"), so I guess that needs to stay. And I guess the first one is to remove an issue with a trailing empty value(s) after the split?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#207 points out that we are not treating trailing blank lines in multipart emails as significant.
This change changes both the parser and the renderer to treat those correctly.
RFC 2046 §5.1.1