From decb38ed4b22be79b0ec33c2b6a18316cf2a9ec1 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 5 May 2017 13:13:18 +0200 Subject: [PATCH] =?UTF-8?q?Fixed=20issue=20#1045=20-=20Subject=20with=20"S?= =?UTF-8?q?ubject:=20=3D=3Fus-ascii=3FQ=3FABC=20/=20123=20/=20Wetterau=20W?= =?UTF-8?q?est=20/=20ABC=3F=3D"=20is=20not=20decoded.?= --- app/models/channel/email_parser.rb | 5 +++++ test/fixtures/mail50.box | 22 ++++++++++++++++++++++ test/unit/email_parser_test.rb | 8 ++++++++ 3 files changed, 35 insertions(+) create mode 100644 test/fixtures/mail50.box diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 994a87dbc..b8b78be9f 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -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] diff --git a/test/fixtures/mail50.box b/test/fixtures/mail50.box new file mode 100644 index 000000000..784269cea --- /dev/null +++ b/test/fixtures/mail50.box @@ -0,0 +1,22 @@ +From martin@example.com Thu May 3 12:04:29 2012 +Return-Path: +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 ; Thu, 3 May 2012 12:04:28 +0100 (BST) +Subject: =?us-ascii?Q?ABC / 123 / Wetterau West / ABC?= +From: +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable +Date: Fri, 4 May 2012 14:01:03 +0200 +Message-Id: +To: metest@znuny.com + +=E4=F6=FC=DF ad asd + +-Martin + +-- +Old programmers never die. They just branch to a new address. diff --git a/test/unit/email_parser_test.rb b/test/unit/email_parser_test.rb index b3f4ffef3..c2a918a81 100644 --- a/test/unit/email_parser_test.rb +++ b/test/unit/email_parser_test.rb @@ -1039,6 +1039,14 @@ end
", }, }, + { + 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',