mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Move validation into form field.
This commit is contained in:
committed by
Martin Gross
parent
447cffa7a8
commit
1b88a84a83
@@ -90,7 +90,7 @@ from pretix.base.settings import (
|
|||||||
COUNTRIES_WITH_STATE_IN_ADDRESS, COUNTRY_STATE_LABEL,
|
COUNTRIES_WITH_STATE_IN_ADDRESS, COUNTRY_STATE_LABEL,
|
||||||
PERSON_NAME_SALUTATIONS, PERSON_NAME_SCHEMES, PERSON_NAME_TITLE_GROUPS,
|
PERSON_NAME_SALUTATIONS, PERSON_NAME_SCHEMES, PERSON_NAME_TITLE_GROUPS,
|
||||||
)
|
)
|
||||||
from pretix.base.templatetags.rich_text import rich_text
|
from pretix.base.templatetags.rich_text import rich_text, URL_RE
|
||||||
from pretix.base.timemachine import time_machine_now
|
from pretix.base.timemachine import time_machine_now
|
||||||
from pretix.control.forms import (
|
from pretix.control.forms import (
|
||||||
ExtFileField, ExtValidationMixin, SizeValidationMixin, SplitDateTimeField,
|
ExtFileField, ExtValidationMixin, SizeValidationMixin, SplitDateTimeField,
|
||||||
@@ -227,6 +227,11 @@ class NamePartsFormField(forms.MultiValueField):
|
|||||||
# bots.
|
# bots.
|
||||||
r'^[^$€/%§{}<>~]*$',
|
r'^[^$€/%§{}<>~]*$',
|
||||||
message=_('Please do not use special characters in names.')
|
message=_('Please do not use special characters in names.')
|
||||||
|
),
|
||||||
|
RegexValidator(
|
||||||
|
URL_RE,
|
||||||
|
inverse_match=True,
|
||||||
|
message=_('Please do not use special characters in names.')
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ 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
|
||||||
|
|
||||||
@@ -151,7 +150,6 @@ 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):
|
||||||
@@ -238,15 +236,6 @@ 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