mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/tglx/remail.git
synced 2024-11-08 05:32:37 +01:00
remail: Use email.utils.parseaddr()
Manual parsing is error prone. Suggested-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
c8ac6b5a08
commit
893b9510db
1 changed files with 2 additions and 5 deletions
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
# Mail message related code
|
||||
|
||||
from email.utils import make_msgid, formatdate
|
||||
from email.utils import make_msgid, formatdate, parseaddr
|
||||
from email.header import Header, decode_header
|
||||
from email import message_from_string, message_from_bytes
|
||||
from email.generator import Generator
|
||||
|
@ -150,10 +150,7 @@ def get_raw_email_addr(addr):
|
|||
'''
|
||||
Return the raw mail address, name and brackets stripped off.
|
||||
'''
|
||||
try:
|
||||
return addr.split('<')[1].split('>')[0].strip()
|
||||
except:
|
||||
return addr
|
||||
return parseaddr(addr)[1]
|
||||
|
||||
re_compress_space = re.compile('\s+')
|
||||
|
||||
|
|
Loading…
Reference in a new issue