From 0b472fae6754e25c0ab9de19abcdc2bd62c0d336 Mon Sep 17 00:00:00 2001 From: Billy Zhou Date: Wed, 30 Jan 2019 23:58:48 +0800 Subject: [PATCH] Follow up to #2456 - removed unnessary call to Mail::Encodings.value_decode and corrected test cases --- app/models/channel/email_parser.rb | 2 +- spec/models/channel/email_parser_spec.rb | 2 +- test/data/mail/mail077.box | 2 +- test/data/mail/mail077.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index bd9669770..ceef9257f 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -508,7 +508,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again h['x-any-recipient'] = h.values.select(&:present?).join(', ') h['message_id'] = imported_fields['message-id'] - h['subject'] = Mail::Encodings.value_decode(imported_fields['subject']) + h['subject'] = imported_fields['subject'] begin h['date'] = Time.zone.parse(mail.date.to_s) || imported_fields['date'] rescue diff --git a/spec/models/channel/email_parser_spec.rb b/spec/models/channel/email_parser_spec.rb index 2c95880ab..d0808313d 100644 --- a/spec/models/channel/email_parser_spec.rb +++ b/spec/models/channel/email_parser_spec.rb @@ -170,7 +170,7 @@ RSpec.describe Channel::EmailParser, type: :model do end it 'decode utf-8 encoded strings' do - expect( Mail::Encodings.value_decode('=?UTF-8?Q?Personal=C3=A4nderung?=') ).to eql( 'Personaländerung' ) + expect( Mail::Encodings.value_decode('=?UTF-8?Q? Personal=C3=A4nderung?=') ).to eql( ' Personaländerung' ) end end end diff --git a/test/data/mail/mail077.box b/test/data/mail/mail077.box index 699a2edd9..c0bbea647 100644 --- a/test/data/mail/mail077.box +++ b/test/data/mail/mail077.box @@ -5,7 +5,7 @@ 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: =?UTF-8?Q?Personal=C3=A4nderung?= +Subject: =?UTF-8?Q? Personal=C3=A4nderung?= From: Content-Type: text/plain; charset=iso-8859-1 diff --git a/test/data/mail/mail077.yml b/test/data/mail/mail077.yml index f6a4a1226..447a2c805 100644 --- a/test/data/mail/mail077.yml +++ b/test/data/mail/mail077.yml @@ -1,2 +1,2 @@ --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess -subject: Personaländerung +subject: ' Personaländerung'