forked from CGM_Public/pretix_original
Improve URL parameter validation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
from django.http import FileResponse, HttpRequest, HttpResponse
|
||||
from django.http import FileResponse, Http404, HttpRequest, HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.functional import cached_property
|
||||
from django.views.generic import TemplateView
|
||||
@@ -13,7 +13,10 @@ class DownloadView(TemplateView):
|
||||
|
||||
@cached_property
|
||||
def object(self) -> CachedFile:
|
||||
return get_object_or_404(CachedFile, id=self.kwargs['id'])
|
||||
try:
|
||||
return get_object_or_404(CachedFile, id=self.kwargs['id'])
|
||||
except ValueError: # Invalid URLs
|
||||
raise Http404()
|
||||
|
||||
def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
|
||||
if 'ajax' in request.GET:
|
||||
|
||||
Reference in New Issue
Block a user