[FIX] ir.mail.server: improve support for user names with emails

The previous fix in revision 5072 only allowed user names
that contained the exact same emails, but users will do
the wildest things like having `someone@domain.com` as
name but setting their email to `someone@domain2.com`.

This was blocked by our sanity check looking for a single
email in the From header. As this check is only done
in order to provide a better error message, it should
not impact valid cases.
Modifying the check to pass when at least one email
was found should be enough to catch most invalid cases,
without requiring a more advanced analysis of the
header value (the RFCs allows very strange things!)

bzr revid: odo@openerp.com-20130918143807-wqqpqomyu1ppa2ih
This commit is contained in:
Olivier Dony 2013-09-18 16:38:07 +02:00
parent f37b2a0db4
commit 130afb812d
1 changed files with 4 additions and 3 deletions

View File

@ -402,9 +402,10 @@ class ir_mail_server(osv.osv):
# The email's "Envelope From" (Return-Path), and all recipient addresses must only contain ASCII characters.
from_rfc2822 = extract_rfc2822_addresses(smtp_from)
assert len(set(from_rfc2822)) == 1, ("Malformed 'Return-Path' or 'From' address: %r - "
"It should contain one plain ASCII email") % smtp_from
smtp_from = from_rfc2822[0]
assert from_rfc2822, ("Malformed 'Return-Path' or 'From' address: %r - "
"It should contain one valid plain ASCII email") % smtp_from
# use last extracted email, to support rarities like 'Support@MyComp <support@mycompany.com>'
smtp_from = from_rfc2822[-1]
email_to = message['To']
email_cc = message['Cc']
email_bcc = message['Bcc']