diff --git a/app/models/avatar.rb b/app/models/avatar.rb index c109cc931..dc7fd832d 100644 --- a/app/models/avatar.rb +++ b/app/models/avatar.rb @@ -123,7 +123,7 @@ add avatar by url data[:full][:content] = content data[:full][:mime_type] = mime_type - elsif data[:url].to_s.match?(/^http/) + elsif data[:url].to_s.match?(%r{^https?://}) url = data[:url].to_s # check if source ist already updated within last 2 minutes @@ -168,7 +168,7 @@ add avatar by url data[:full][:mime_type] = mime_type # try zammad backend to find image based on email - elsif data[:url].to_s.match?(/@/) + elsif data[:url].to_s.match?(URI::MailTo::EMAIL_REGEXP) url = data[:url].to_s # check if source ist already updated within last 3 minutes @@ -179,9 +179,7 @@ add avatar by url # fetch image image = Service::Image.user(url) return if !image - data[:resize] ||= {} data[:resize] = image - data[:full] ||= {} data[:full] = image end end diff --git a/test/data/mail/mail070.box b/test/data/mail/mail070.box new file mode 100644 index 000000000..502441e3e --- /dev/null +++ b/test/data/mail/mail070.box @@ -0,0 +1,16 @@ +Return-Path: +Delivered-To: xxx +Received: from xxx + for ; Tue, 21 Aug 2018 09:49:58 +0000 +To: xxx +From: "http.abc" +Subject: test +Message-ID: +Date: Tue, 21 Aug 2018 11:49:57 +0200 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:xxx) Gecko/xxx + Thunderbird/xxx +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: clamav-milter 0.100.1 +X-Virus-Status: Clean diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index 5da8e70a5..7c3f952a3 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -3094,6 +3094,27 @@ Content-Type: text/html; charset=us-ascii; format=flowed ], }, }, + { # See https://github.com/zammad/zammad/issues/2199 + data: File.read(Rails.root.join('test', 'data', 'mail', 'mail070.box')), + success: true, + result: { + 1 => { + from: '"http.abc" ', + sender: 'Customer', + type: 'email', + }, + }, + verify: { + users: [ + { + firstname: 'http.abc', + lastname: '', + fullname: 'http.abc', + email: 'http.abc@example.com', + }, + ], + }, + }, ] assert_process(files) end