mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +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):
|
||||
if "emptybackground" in request.POST:
|
||||
p = PdfFileWriter()
|
||||
p.addBlankPage(
|
||||
width=float(request.POST.get('width')) * mm,
|
||||
height=float(request.POST.get('height')) * mm,
|
||||
)
|
||||
try:
|
||||
p.addBlankPage(
|
||||
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()
|
||||
p.write(buffer)
|
||||
buffer.seek(0)
|
||||
|
||||
Reference in New Issue
Block a user