Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseMediaType tolerates unencoded 8bit characters #201

Merged
merged 5 commits into from Jul 15, 2021

Conversation

pavelbazika
Copy link
Contributor

Hi,

I'm here with yet another RFC violation tolerance pull request.

Some emails does not encode mime param with RFC 2047 encoding when they should. I.e when there are some characters with unicode value out of US-ASCII (> 127). Namely a chinese client Foxmail created such emails at least in the past.

I've improved the function consumeParam used by fixUnquotedSpecials to check for such violation and when it occurs, it encodes the value with RFC 2017.

It's expected that the bytes are in UTF-8 encoding, but when not, the invalid bytes are encoded to base64 too. As a result,. ReadEnvelope does not end with error when an email with wrongly encoded attachment part is parsed and at least something (headers, body) is readable.

Copy link
Owner

@jhillyerd jhillyerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, couple change requests. Can we also add a single test for ReadEnvelope as well to prevent future changes from defeating this fix?

header.go Outdated Show resolved Hide resolved
header.go Outdated Show resolved Hide resolved
@jhillyerd jhillyerd merged commit 0c598a7 into jhillyerd:master Jul 15, 2021
@jhillyerd
Copy link
Owner

Thanks!

@pavelbazika pavelbazika deleted the mangled8bit branch July 26, 2021 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants