Fixed issue #763 - Customer names are sometimes wrapped with quotes.

This commit is contained in:
Martin Edenhofer 2017-03-16 06:50:01 +01:00
parent 2d48100792
commit 73a258b796
3 changed files with 84 additions and 5 deletions

View file

@ -129,8 +129,7 @@ class Channel::EmailParser
data[:from_email] = "#{$2}@#{$3}"
data[:from_local] = $2
data[:from_domain] = $3
data[:from_display_name] = $1.strip
data[:from_display_name].delete!('"')
data[:from_display_name] = $1
else
data[:from_email] = from
data[:from_local] = from
@ -140,6 +139,10 @@ class Channel::EmailParser
# do extra decoding because we needed to use field.value
data[:from_display_name] = Mail::Field.new('X-From', data[:from_display_name]).to_s
data[:from_display_name].delete!('"')
data[:from_display_name].strip!
data[:from_display_name].gsub!(/^'/, '')
data[:from_display_name].gsub!(/'$/, '')
# compat headers
data[:message_id] = data['message-id'.to_sym]

View file

@ -112,7 +112,7 @@ module Channel::Filter::IdentifySender
address = $1
end
if recipient =~ /^(.+?)<(.+?)>/
display_name = ($1).strip
display_name = $1
end
next if address.empty?
user_create(
@ -135,8 +135,12 @@ module Channel::Filter::IdentifySender
# check if firstname or lastname need to be updated
if user
if user.firstname.empty? && user.lastname.empty?
if !data[:firstname].empty?
if user.firstname.blank? && user.lastname.blank?
if data[:firstname].present?
data[:firstname].strip!
data[:firstname].delete!('"')
data[:firstname].gsub!(/^'/, '')
data[:firstname].gsub!(/'$/, '')
user.update_attributes(
firstname: data[:firstname]
)
@ -153,6 +157,10 @@ module Channel::Filter::IdentifySender
if data[item.to_sym].nil?
data[item.to_sym] = ''
end
data[item.to_sym].strip!
data[item.to_sym].delete!('"')
data[item.to_sym].gsub!(/^'/, '')
data[item.to_sym].gsub!(/'$/, '')
}
data[:password] = ''
data[:active] = true

View file

@ -1862,6 +1862,74 @@ AElFTkSuQmCC
},
},
},
{
data: 'From: =?UTF-8?Q?=22Frieda_H=C3=B6flich1=22?= <frieda.hoeflich1@example.com>
To: =?UTF-8?Q?=22Bob1=22?= <bod+frieda.hoeflich1@example.com>
Subject: some subject frieda hoeflich1
Some Text',
success: true,
result: {
0 => {
priority: '2 normal',
title: 'some subject frieda hoeflich1',
},
1 => {
sender: 'Customer',
type: 'email',
},
},
verify: {
users: [
{
firstname: 'Frieda',
lastname: 'Höflich1',
fullname: 'Frieda Höflich1',
email: 'frieda.hoeflich1@example.com',
},
{
firstname: 'Bob1',
lastname: '',
fullname: 'Bob1',
email: 'bod+frieda.hoeflich1@example.com',
},
],
}
},
{
data: 'From: =?utf-8?Q?=27Frieda_H=C3=B6flich2=27?= <frieda.hoeflich2@example.com>
To: =?utf-8?Q?=27Bob2=27?= <bod+frieda.hoeflich2@example.com>
Subject: some subject frieda hoeflich2
Some Text',
success: true,
result: {
0 => {
priority: '2 normal',
title: 'some subject frieda hoeflich2',
},
1 => {
sender: 'Customer',
type: 'email',
},
},
verify: {
users: [
{
firstname: 'Frieda',
lastname: 'Höflich2',
fullname: 'Frieda Höflich2',
email: 'frieda.hoeflich2@example.com',
},
{
firstname: 'Bob2',
lastname: '',
fullname: 'Bob2',
email: 'bod+frieda.hoeflich2@example.com',
},
],
}
},
{
data: 'From: Some Body <somebody@example.com>
To: Bob <bod@example.com>