diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 24eb6f7cffc..9906e7e49f9 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -166,7 +166,9 @@ module Email def try_to_encode(string, encoding) string.encode("UTF-8", encoding) - rescue Encoding::InvalidByteSequenceError, Encoding::UndefinedConversionError + rescue Encoding::InvalidByteSequenceError, + Encoding::UndefinedConversionError, + Encoding::ConverterNotFoundError nil end diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index 697231e4330..9225e8277d8 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -109,6 +109,9 @@ describe Email::Receiver do expect { process(:chinese_reply) }.to change { topic.posts.count } expect(topic.posts.last.raw).to eq("您好! 你今天好吗?") + + expect { process(:reply_with_weird_encoding) }.to change { topic.posts.count } + expect(topic.posts.last.raw).to eq("This is a reply with a weird encoding.") end it "prefers text over html" do diff --git a/spec/fixtures/emails/reply_with_weird_encoding.eml b/spec/fixtures/emails/reply_with_weird_encoding.eml new file mode 100644 index 00000000000..c764584e802 --- /dev/null +++ b/spec/fixtures/emails/reply_with_weird_encoding.eml @@ -0,0 +1,9 @@ +Return-Path: +From: Foo Bar +To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com +Date: Fri, 15 Jan 2016 00:12:43 +0100 +Message-ID: <42@foo.bar.mail> +Mime-Version: 1.0 +Content-Type: text/plain; charset=unicode-1-1-utf-7 + +This is a reply with a weird encoding.