Skip to content

Commit

Permalink
util: Use email.utils.parseaddr for strip_email
Browse files Browse the repository at this point in the history
this handles quoted values correctly and we avoid reinventing the wheel.
  • Loading branch information
The-Compiler committed Sep 17, 2024
1 parent 710ba1d commit 3a23cc9
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions dodo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,7 @@ def strip_email_address(e: str) -> str:
E.g. "First Last <me@domain.com>" -> "me@domain.com"
"""

# TODO proper handling of quoted strings
head = re.compile('^.*<')
tail = re.compile('>.*$')
return tail.sub('', head.sub('', e))
return email.utils.parseaddr(e)[1]

def email_is_me(e: str) -> bool:
"""Check whether the provided email is me
Expand Down

0 comments on commit 3a23cc9

Please sign in to comment.