1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-22 02:17:26 +00: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

@ -26,6 +26,7 @@ Control panel:
* Fixed the jumpiness when a modal is displayed. * Fixed the jumpiness when a modal is displayed.
* Focus is put into the login form fields when the login form is displayed. * Focus is put into the login form fields when the login form is displayed.
* Status checks now include a warning if a custom DNS record has been set on a domain that would normally serve web and as a result that domain no longer is serving web. * Status checks now include a warning if a custom DNS record has been set on a domain that would normally serve web and as a result that domain no longer is serving web.
* Some errors in the control panel when there is invalid data in the database or an improperly named archived user account have been suppressed.
v0.13b (August 30, 2015) v0.13b (August 30, 2015)
------------------------ ------------------------

View File

@ -244,7 +244,13 @@ def get_domain(emailaddr, as_unicode=True):
# Gets the domain part of an email address. Turns IDNA # Gets the domain part of an email address. Turns IDNA
# back to Unicode for display. # back to Unicode for display.
ret = emailaddr.split('@', 1)[1] 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 return ret
def get_mail_domains(env, filter_aliases=lambda alias : True): def get_mail_domains(env, filter_aliases=lambda alias : True):

View File

@ -263,8 +263,14 @@ def run_domain_checks(rounded_time, env, output, pool):
def run_domain_checks_on_domain(domain, rounded_time, env, dns_domains, dns_zonefiles, mail_domains, web_domains, domains_with_a_records): def run_domain_checks_on_domain(domain, rounded_time, env, dns_domains, dns_zonefiles, mail_domains, web_domains, domains_with_a_records):
output = BufferedOutput() output = BufferedOutput()
# The domain is IDNA-encoded, but for display use Unicode. # The domain is IDNA-encoded in the database, but for display use Unicode.
output.add_heading(idna.decode(domain.encode('ascii'))) try:
domain_display = idna.decode(domain.encode('ascii'))
output.add_heading(domain_display)
except (ValueError, UnicodeError, idna.IDNAError) as e:
# Looks like we have some invalid data in our database.
output.add_heading(domain)
output.print_error("Domain name is invalid: " + str(e))
if domain == env["PRIMARY_HOSTNAME"]: if domain == env["PRIMARY_HOSTNAME"]:
check_primary_hostname_dns(domain, env, output, dns_domains, dns_zonefiles) check_primary_hostname_dns(domain, env, output, dns_domains, dns_zonefiles)