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

Fix exception when multibyte UTF-8 chars are in multipart boundary. #1601

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pdg137
Copy link

@pdg137 pdg137 commented Feb 6, 2024

The gem splits multipart emails on a boundary string using a Regex, but this fails on certain invalid emails when the boundary is interpreted as UTF-8 and the body is considered ASCII-8BIT, causing an exception:

Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)

I changed it to detect that case and simply force the encoding of boundary to ASCII-8BIT so it can work without exception. Not sure if it should do something smarter, but this seems to at least work for the tiny fraction of emails that have this problem.

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

1 participant