From 86430e9e3387cd31302fa3e2171cb6932792076b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 30 Jul 2017 09:37:36 +0200 Subject: [PATCH] Improved error handling. --- app/models/channel/filter/identify_sender.rb | 7 ++- test/unit/email_process_test.rb | 57 ++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/app/models/channel/filter/identify_sender.rb b/app/models/channel/filter/identify_sender.rb index e8594c3cc..c324abae7 100644 --- a/app/models/channel/filter/identify_sender.rb +++ b/app/models/channel/filter/identify_sender.rb @@ -103,13 +103,16 @@ module Channel::Filter::IdentifySender rescue => e # parse not parseable fields by mail gem like # - Max Kohl | [example.com] + # - Max Kohl Rails.logger.error 'ERROR: ' + e.inspect - Rails.logger.error 'ERROR: try it by my self' + Rails.logger.error "ERROR: try it by my self (#{item}): #{mail[item.to_sym]}" recipients = mail[item.to_sym].to_s.split(',') recipients.each { |recipient| address = nil display_name = nil - if recipient =~ /<(.+?)>/ + if recipient =~ /.*<(.+?)>/ + address = $1 + elsif recipient =~ /<(.+?)>/ address = $1 end if recipient =~ /^(.+?)<(.+?)>/ diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index 3e4627d50..96658dcc9 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -136,6 +136,63 @@ Some Textäöü".encode('ISO-8859-1'), }, { data: "From: me@example.com +To: Alexander Ha , + Alexander Re , Hauke Ko + , Jens Ro , + =?UTF-8?Q?B=c3=bc_Yi?= , + Ja Bl , + \"lars.73@example.de\" , + Luk Hl , + =?UTF-8?Q?Ma_Gr=c3=b6ner_, + Malte Bi , =?UTF-8?Q?Ma_Bfu=c3=9f?= + , Marco Fe , + heidt@example.de, matt.ga@example.com, + Nick Ku , Sergej I , + Thomas Ga , + Peter Wo , + =?UTF-8?B?SsO8cmdlbiB2b24gUsO2bm4=?= , + Frank-Ingo Br +Subject: test 1 + +test 1", + success: true, + result: { + 0 => { + priority: '2 normal', + title: 'test 1', + }, + 1 => { + body: 'test 1', + sender: 'Customer', + type: 'email', + internal: false, + }, + }, + verify: { + users: [ + { + firstname: 'Alexander', + lastname: 'Ha', + fullname: 'Alexander Ha', + email: 'service-d1@example.com', + }, + { + firstname: 'Alexander', + lastname: 'Re', + fullname: 'Alexander Re', + email: 're-mail@example.de', + }, + { + firstname: 'Ma', + lastname: 'Gröner', + fullname: 'Ma Gröner', + email: 'ma.g@example.com', + }, + ], + } + }, + { + data: "From: me@example.com To: customer@example.com Subject: Subject: =?utf-8?B?44CQ5LiT5Lia5Li65oKo5rOo5YaM6aaZ5riv5Y+K5rW35aSW5YWs5Y+477yI5aW95aSE5aSa5aSa77yJ?= =?utf-8?B?44CR44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=