1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-18 18:07:22 +01:00

silence errors in the admin if there is an invalid domain name in the database

see #531
This commit is contained in:
Joshua Tauberer
2015-09-06 13:24:15 +00:00
parent 3e96de26dd
commit 6704da1446
3 changed files with 16 additions and 3 deletions

View File

@@ -244,7 +244,13 @@ def get_domain(emailaddr, as_unicode=True):
# Gets the domain part of an email address. Turns IDNA
# back to Unicode for display.
ret = emailaddr.split('@', 1)[1]
if as_unicode: ret = idna.decode(ret.encode('ascii'))
if as_unicode:
try:
ret = idna.decode(ret.encode('ascii'))
except (ValueError, UnicodeError, idna.IDNAError):
# Looks like we have an invalid email address in
# the database. Now is not the time to complain.
pass
return ret
def get_mail_domains(env, filter_aliases=lambda alias : True):