Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
forms: Fix another 500 error on realm creation with invalid email.
Anders Kaseorg92f9a9ba419e
diff --git a/zerver/forms.py b/zerver/forms.pyindex 7434ec24582..f866375d6d0 100644--- a/zerver/forms.py+++ b/zerver/forms.py@@ -1,5 +1,6 @@import loggingimport re+from email.errors import HeaderParseErrorfrom email.headerregistry import Addressfrom typing import Any, Dict, List, Optional, Tuple@@ -243,7 +244,7 @@ def email_not_system_bot(email: str) -> None:def email_is_not_disposable(email: str) -> None:try:domain = Address(addr_spec=email).domain- except ValueError:+ except (HeaderParseError, ValueError):raise ValidationError(_("Please use your real email address."))if is_disposable_domain(domain):diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex c0afffe9450..b46a3717833 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -3797,6 +3797,9 @@ class RealmCreationTest(ZulipTestCase):@override_settings(OPEN_REALM_CREATION=True)def test_invalid_email_signup(self) -> None:+ result = self.client_post("/new/", {"email": "<foo"})+ self.assert_in_response("Please use your real email address.", result)+result = self.client_post("/new/", {"email": "foo\x00bar"})self.assert_in_response("Please use your real email address.", result)