mirror of
https://github.com/pretix/pretix.git
synced 2026-04-11 21:22:29 +00:00
Compare commits
3 Commits
customerac
...
filter-nul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a88af3fca | ||
|
|
221cbd15ab | ||
|
|
5c7104634e |
@@ -1122,7 +1122,7 @@ class CheckinViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
permission = 'event.orders:read'
|
||||
|
||||
def get_queryset(self):
|
||||
qs = Checkin.all.filter().select_related(
|
||||
qs = Checkin.all.filter(list__event=self.request.event).select_related(
|
||||
"position",
|
||||
"device",
|
||||
)
|
||||
|
||||
@@ -24,6 +24,7 @@ from urllib.parse import urlparse, urlsplit
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import BadRequest
|
||||
from django.http import Http404, HttpRequest, HttpResponse
|
||||
from django.middleware.common import CommonMiddleware
|
||||
from django.urls import get_script_prefix, resolve
|
||||
@@ -346,6 +347,15 @@ class SecurityMiddleware(MiddlewareMixin):
|
||||
|
||||
return resp
|
||||
|
||||
def process_request(self, request):
|
||||
# Nullbytes in GET/POST parameters are mostly harmless, as they will later fail on database insertion, but it
|
||||
# keeps spamming our error logs whenever someone tries to run a vulnerability scanner.
|
||||
if "\x00" in request.META['QUERY_STRING'] or "%00" in request.META['QUERY_STRING']:
|
||||
raise BadRequest("Invalid characters in input.")
|
||||
if request.method in ('POST', 'PUT', 'PATCH') and request.POST:
|
||||
if any("\x00" in value for key, value_list in request.POST.lists() for value in value_list):
|
||||
raise BadRequest("Invalid characters in input.")
|
||||
|
||||
|
||||
class CustomCommonMiddleware(CommonMiddleware):
|
||||
|
||||
|
||||
@@ -70,6 +70,10 @@ def parse_csv(file, length=None, mode="strict", charset=None):
|
||||
except ImportError:
|
||||
charset = file.charset
|
||||
data = data.decode(charset or "utf-8", mode)
|
||||
|
||||
# remove stray linebreaks from the end of the file
|
||||
data = data.rstrip("\n")
|
||||
|
||||
# If the file was modified on a Mac, it only contains \r as line breaks
|
||||
if '\r' in data and '\n' not in data:
|
||||
data = data.replace('\r', '\n')
|
||||
|
||||
@@ -991,3 +991,30 @@ def test_import_mixed_order_size_consistency(user, event, item):
|
||||
).get()
|
||||
assert ('Inconsistent data in row 2: Column Email address contains value "a2@example.com", but for this order, '
|
||||
'the value has already been set to "a1@example.com".') in str(excinfo.value)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@scopes_disabled()
|
||||
def test_import_line_endings_mix(event, item, user):
|
||||
# Ensures import works with mixed file endings.
|
||||
# See Ticket#23230806 where a file to import ends with \r\n
|
||||
settings = dict(DEFAULT_SETTINGS)
|
||||
settings['item'] = 'static:{}'.format(item.pk)
|
||||
|
||||
cf = inputfile_factory()
|
||||
file = cf.file
|
||||
file.seek(0)
|
||||
data = file.read()
|
||||
data = data.replace(b'\n', b'\r')
|
||||
data = data.rstrip(b'\r\r')
|
||||
data = data + b'\r\n'
|
||||
|
||||
print(data)
|
||||
cf.file.save("input.csv", ContentFile(data))
|
||||
cf.save()
|
||||
|
||||
import_orders.apply(
|
||||
args=(event.pk, cf.id, settings, 'en', user.pk)
|
||||
)
|
||||
assert event.orders.count() == 3
|
||||
assert OrderPosition.objects.count() == 3
|
||||
|
||||
Reference in New Issue
Block a user