Skip to content

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

Open
pdg137 wants to merge 1 commit intomikel:masterfrom
pdg137:utf8_boundary
Open

Fix exception when multibyte UTF-8 chars are in multipart boundary.#1601
pdg137 wants to merge 1 commit intomikel:masterfrom
pdg137:utf8_boundary

Conversation

@pdg137
Copy link
Copy Markdown

@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.

1 participant