mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FIX: support emails in with weird encoding
This commit is contained in:
parent
01f2f05f2d
commit
841cec1bc1
3 changed files with 15 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
9
spec/fixtures/emails/reply_with_weird_encoding.eml
vendored
Normal file
9
spec/fixtures/emails/reply_with_weird_encoding.eml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
Return-Path: <discourse@bar.com>
|
||||
From: Foo Bar <discourse@bar.com>
|
||||
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.
|
Loading…
Reference in a new issue