Commit 6704da14 authored by Joshua Tauberer's avatar Joshua Tauberer

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

see #531
parent 3e96de26
...@@ -26,6 +26,7 @@ Control panel: ...@@ -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)
------------------------ ------------------------
......
...@@ -244,7 +244,13 @@ def get_domain(emailaddr, as_unicode=True): ...@@ -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):
......
...@@ -263,8 +263,14 @@ def run_domain_checks(rounded_time, env, output, pool): ...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment