Skip to content

Commit d56560e

Browse files
committed
Throw a validation error if a profile name contains an @ sign upon
edit so that people do not forget to enter their name. Commit ready for merge. - Legacy-Id: 11750
1 parent 21c33f0 commit d56560e

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

ietf/ietfauth/forms.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def ascii_cleaner(supposedly_ascii):
4848
raise forms.ValidationError("Please only enter ASCII characters.")
4949
return supposedly_ascii
5050

51+
def prevent_at_symbol(name):
52+
if "@" in name:
53+
raise forms.ValidationError("Please fill in name - this looks like an email address (@ is not allowed in names).")
54+
5155
def get_person_form(*args, **kwargs):
5256

5357
exclude_list = ['time', 'user', 'photo_thumb', 'photo', ]
@@ -65,11 +69,20 @@ class Meta:
6569
def __init__(self, *args, **kwargs):
6670
super(ModelForm, self).__init__(*args, **kwargs)
6771

72+
def clean_name(self):
73+
name = self.cleaned_data.get("name") or u""
74+
prevent_at_symbol(name)
75+
return name
76+
6877
def clean_ascii(self):
69-
return ascii_cleaner(self.cleaned_data.get("ascii") or u"")
78+
name = self.cleaned_data.get("ascii") or u""
79+
prevent_at_symbol(name)
80+
return ascii_cleaner(name)
7081

7182
def clean_ascii_short(self):
72-
return ascii_cleaner(self.cleaned_data.get("ascii_short") or u"")
83+
name = self.cleaned_data.get("ascii_short") or u""
84+
prevent_at_symbol(name)
85+
return ascii_cleaner(name)
7386

7487
return PersonForm(*args, **kwargs)
7588

0 commit comments

Comments
 (0)