FIX: Catch UndefinedConversionError for inbound emails (#13000)

Some emails coming in via the mail receiver can still end up
with bad encoding when trying to enqueue the job. This catches
the last encoding issue and forces iso-8559-1 and encodes to
UTF-8 to circumvent the issue.
This commit is contained in:
Martin Brennan
2021-05-10 14:26:23 +10:00
committed by GitHub
parent aaa034786a
commit c187ede3c6
3 changed files with 19 additions and 1 deletions

View File

@ -158,7 +158,7 @@ class Admin::EmailController < Admin::AdminController
begin
Jobs.enqueue(:process_email, mail: email_raw, retry_on_rate_limit: true, source: :handle_mail)
rescue JSON::GeneratorError => e
rescue JSON::GeneratorError, Encoding::UndefinedConversionError => e
if retry_count == 0
email_raw = email_raw.force_encoding('iso-8859-1').encode("UTF-8")
retry_count += 1