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 dc88758 commit 780dfff
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 @@ -284,11 +284,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(r'^.*<')
tail = re.compile(r'>.*$')
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 780dfff

Please sign in to comment.