forked from CGM_Public/pretix_original
Customer Accounts: Limit length; reject URLs in name
This commit is contained in:
committed by
Martin Gross
parent
6d255bb9cc
commit
447cffa7a8
@@ -43,6 +43,7 @@ from pretix.base.forms.questions import (
|
|||||||
)
|
)
|
||||||
from pretix.base.i18n import get_language_without_region
|
from pretix.base.i18n import get_language_without_region
|
||||||
from pretix.base.models import Customer
|
from pretix.base.models import Customer
|
||||||
|
from pretix.base.templatetags.rich_text import URL_RE
|
||||||
from pretix.helpers.http import get_client_ip
|
from pretix.helpers.http import get_client_ip
|
||||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||||
|
|
||||||
@@ -150,6 +151,7 @@ class RegistrationForm(forms.Form):
|
|||||||
"instead."
|
"instead."
|
||||||
),
|
),
|
||||||
'required': _('This field is required.'),
|
'required': _('This field is required.'),
|
||||||
|
'invalid_characters': _('Please do not use special characters in names.'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, request=None, *args, **kwargs):
|
def __init__(self, request=None, *args, **kwargs):
|
||||||
@@ -172,7 +174,7 @@ class RegistrationForm(forms.Form):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.fields['name_parts'] = NamePartsFormField(
|
self.fields['name_parts'] = NamePartsFormField(
|
||||||
max_length=255,
|
max_length=35,
|
||||||
required=True,
|
required=True,
|
||||||
scheme=request.organizer.settings.name_scheme,
|
scheme=request.organizer.settings.name_scheme,
|
||||||
titles=request.organizer.settings.name_scheme_titles,
|
titles=request.organizer.settings.name_scheme_titles,
|
||||||
@@ -236,6 +238,15 @@ class RegistrationForm(forms.Form):
|
|||||||
code='duplicate',
|
code='duplicate',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Since the name is user-controlled and can end up in emails sent to customers
|
||||||
|
# we want to sanitize for domains and avoid becoming part of a spamming operation.
|
||||||
|
for name_part in self.cleaned_data.get('name_parts', {}).values():
|
||||||
|
if URL_RE.search(name_part):
|
||||||
|
raise forms.ValidationError(
|
||||||
|
{'name_parts': self.error_messages['invalid_characters']},
|
||||||
|
code='invalid_characters',
|
||||||
|
)
|
||||||
|
|
||||||
if self.standalone:
|
if self.standalone:
|
||||||
expect = -1
|
expect = -1
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user