mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
PDF editor: Catch ValueError during float conversion
This commit is contained in:
@@ -123,10 +123,16 @@ class BaseEditorView(EventPermissionRequiredMixin, TemplateView):
|
|||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
if "emptybackground" in request.POST:
|
if "emptybackground" in request.POST:
|
||||||
p = PdfFileWriter()
|
p = PdfFileWriter()
|
||||||
p.addBlankPage(
|
try:
|
||||||
width=float(request.POST.get('width')) * mm,
|
p.addBlankPage(
|
||||||
height=float(request.POST.get('height')) * mm,
|
width=float(request.POST.get('width')) * mm,
|
||||||
)
|
height=float(request.POST.get('height')) * mm,
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
return JsonResponse({
|
||||||
|
"status": "error",
|
||||||
|
"error": "Invalid height/width given."
|
||||||
|
})
|
||||||
buffer = BytesIO()
|
buffer = BytesIO()
|
||||||
p.write(buffer)
|
p.write(buffer)
|
||||||
buffer.seek(0)
|
buffer.seek(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user