Fix email cleaning to catch recent brokenness on the form "<bound method TempIdAuthors.email of <TempIdAuthors: XXX XXX <xxx@yyy.zzz>>>"

- Legacy-Id: 3156
This commit is contained in:
Ole Laursen 2011-05-26 12:20:10 +00:00
parent 7f6f9a35da
commit fd23dc9d5d

View file

@ -1,7 +1,9 @@
from person.models import Person
def clean_email_address(addr):
addr = addr.replace("<", "").replace(">", "").replace("!", "@").replace("(at)", "@").strip()
addr = addr.replace("!", "@").replace("(at)", "@") # some obvious @ replacements
addr = addr[addr.rfind('<') + 1:addr.find('>')] # whack surrounding <...>
addr = addr.strip()
if not "@" in addr:
return ""
else: