From d6c409444dca3d204d021f7b41e007460b77bab4 Mon Sep 17 00:00:00 2001 From: "Djamel (otd)" Date: Tue, 25 May 2021 09:29:02 +0000 Subject: [PATCH] [FIX] website_slides: set PdfFileReader to strict=False Steps to reproduce the bug: - Go to elearning app > Courses > content - Create new slide > Upload a PDF file with faulty content Problem : Pypdf2 throws errors because it does not support some content or syntax. In our case we are just trying to get the number of pages in the PDF, so if we put `strict = false` we just determine that the user should not be informed of all the errors that pypdf2 encounters, the flag `strict` is not a security indicator. FYI: https://pythonhosted.org/PyPDF2/PdfFileReader.html ``` strict (bool) - Determines whether user should be warned of all problems and also causes some correctable problems to be fatal. Defaults to True.``` opw-2530829 closes odoo/odoo#71756 X-original-commit: 3acd0d666af56c39e34fc551e182468cc7bedc42 Signed-off-by: Djamel Touati --- addons/website_slides/models/slide_slide.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py index e5f272036d4..8c8c3474bce 100644 --- a/addons/website_slides/models/slide_slide.py +++ b/addons/website_slides/models/slide_slide.py @@ -378,7 +378,7 @@ class Slide(models.Model): if self.datas: data = base64.b64decode(self.datas) if data.startswith(b'%PDF-'): - pdf = PyPDF2.PdfFileReader(io.BytesIO(data), overwriteWarnings=False) + pdf = PyPDF2.PdfFileReader(io.BytesIO(data), overwriteWarnings=False, strict=False) self.completion_time = (5 * len(pdf.pages)) / 60 else: self.slide_type = 'infographic'