Fixed issue #1045 - Subject with "Subject: =?us-ascii?Q?ABC / 123 / Wetterau West / ABC?=" is not decoded.

This commit is contained in:
Martin Edenhofer 2017-05-05 13:13:18 +02:00
parent 0bd0693de9
commit decb38ed4b
3 changed files with 35 additions and 0 deletions

View file

@ -144,6 +144,11 @@ class Channel::EmailParser
data[:from_display_name].gsub!(/^'/, '')
data[:from_display_name].gsub!(/'$/, '')
# do extra encoding (see issue#1045)
if data[:subject].present?
data[:subject].sub!(/^=\?us-ascii\?Q\?(.+)\?=$/, '\1')
end
# compat headers
data[:message_id] = data['message-id'.to_sym]

22
test/fixtures/mail50.box vendored Normal file
View file

@ -0,0 +1,22 @@
From martin@example.com Thu May 3 12:04:29 2012
Return-Path: <martin@example.com>
X-Original-To: info@example.com
Delivered-To: box@samba.example.com
Received: from me.home (1-2-1-1.adsl.highway.example.com [1.2.1.1])
by samba.example.com (Postfix) with ESMTPSA id C96F8500D3D
for <info@example.com>; Thu, 3 May 2012 12:04:28 +0100 (BST)
Subject: =?us-ascii?Q?ABC / 123 / Wetterau West / ABC?=
From: <John.Smith@example.com>
Content-Type: text/plain;
charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Date: Fri, 4 May 2012 14:01:03 +0200
Message-Id: <BC182994-03FA-4DC5-8202-98CBFACA0887@example.com>
To: metest@znuny.com
=E4=F6=FC=DF ad asd
-Martin
--
Old programmers never die. They just branch to a new address.

View file

@ -1039,6 +1039,14 @@ end
</div><br><div><img src=\"cid:485376C9-2486-4351-B932-E2010998F579@home\" style=\"width:640px;height:425px;\"></div></div>",
},
},
{
data: IO.binread('test/fixtures/mail50.box'),
body_md5: '154c7d3ae7b94f99589df62882841b08',
attachments: [],
params: {
subject: 'ABC / 123 / Wetterau West / ABC',
},
},
{
data: IO.binread('test/fixtures/mail51.box'),
body_md5: '64675a479f80a674eb7c08e385c3622a',