Browse Source

Handle excessively long email addresses in the signup form.

pull/415/head
Pēteris Caune 4 years ago
parent
commit
ffafc16fe5
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 14 additions and 0 deletions
  1. +3
    -0
      CHANGELOG.md
  2. +3
    -0
      hc/accounts/forms.py
  3. +8
    -0
      hc/accounts/tests/test_signup.py

+ 3
- 0
CHANGELOG.md View File

@ -7,6 +7,9 @@ All notable changes to this project will be documented in this file.
- Django 3.1
- Handle status callbacks from Twilio, show delivery failures in Integrations
## Bug Fixes
- Handle excessively long email addresses in the signup form.
## v1.16.0 - 2020-08-04
### Improvements


+ 3
- 0
hc/accounts/forms.py View File

@ -20,6 +20,9 @@ class AvailableEmailForm(forms.Form):
def clean_identity(self):
v = self.cleaned_data["identity"]
if len(v) > 254:
raise forms.ValidationError("Address is too long.")
if User.objects.filter(email=v).exists():
raise forms.ValidationError(
"An account with this email address already exists."


+ 8
- 0
hc/accounts/tests/test_signup.py View File

@ -81,3 +81,11 @@ class SignupTestCase(TestCase):
form = {"identity": "alice at example org"}
r = self.client.post("/accounts/signup/", form)
self.assertContains(r, "Enter a valid email address")
def test_it_checks_length(self):
aaa = "a" * 300
form = {"identity": f"alice+{aaa}@example.org"}
r = self.client.post("/accounts/signup/", form)
self.assertContains(r, "Address is too long.")
self.assertFalse(User.objects.exists())

Loading…
Cancel
Save