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

@ -229,6 +229,12 @@ describe Admin::EmailController do
expect(response.status).to eq(200)
expect(response.body).to eq("email has been received and is queued for processing")
end
it "retries enqueueing with forced UTF-8 encoding when encountering Encoding::UndefinedConversionError" do
post "/admin/email/handle_mail.json", params: { email_encoded: Base64.strict_encode64(email('encoding_undefined_conversion')) }
expect(response.status).to eq(200)
expect(response.body).to eq("email has been received and is queued for processing")
end
end
describe '#rejected' do