Improve 'URL' parsing in Avatar model (fixes #2199)
This commit is contained in:
parent
f0690f8754
commit
f046c80c79
3 changed files with 39 additions and 4 deletions
|
@ -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
|
||||
|
|
16
test/data/mail/mail070.box
Normal file
16
test/data/mail/mail070.box
Normal file
|
@ -0,0 +1,16 @@
|
|||
Return-Path: <http.abc@example.com>
|
||||
Delivered-To: xxx
|
||||
Received: from xxx
|
||||
for <xxx>; Tue, 21 Aug 2018 09:49:58 +0000
|
||||
To: xxx
|
||||
From: "http.abc" <http.abc@example.com>
|
||||
Subject: test
|
||||
Message-ID: <xxx>
|
||||
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
|
|
@ -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" <http.abc@example.com>',
|
||||
sender: 'Customer',
|
||||
type: 'email',
|
||||
},
|
||||
},
|
||||
verify: {
|
||||
users: [
|
||||
{
|
||||
firstname: 'http.abc',
|
||||
lastname: '',
|
||||
fullname: 'http.abc',
|
||||
email: 'http.abc@example.com',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
assert_process(files)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue