From e9c2dc90d5e19273414dbc12fcf10086ba9a4cac Mon Sep 17 00:00:00 2001 From: Finn Stutzenstein Date: Mon, 15 Feb 2021 07:22:38 +0100 Subject: [PATCH] Catch pyPDF2 key error --- server/openslides/mediafiles/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/openslides/mediafiles/utils.py b/server/openslides/mediafiles/utils.py index 67204a8d6..c9aef9666 100644 --- a/server/openslides/mediafiles/utils.py +++ b/server/openslides/mediafiles/utils.py @@ -20,8 +20,9 @@ def get_pdf_information(mediafile): try: pdf = PdfFileReader(mediafile) result["pages"] = pdf.getNumPages() - except PdfReadError: + except (PdfReadError, KeyError): # File could be encrypted but not be detected by PyPDF. + # KeyError: https://github.com/mstamy2/PyPDF2/issues/353 Very rare to occur, but do not raise a 500 result["pages"] = 0 result["encrypted"] = True return result