Skip to content

Commit

Permalink
Backport of odoo/addons/base/tests/minimal.pdf
Browse files Browse the repository at this point in the history
Our updated version of PyPDF2 (1.27.12) has broken TestPdf tests
with PyPDF2.errors.PdfReadError: Broken xref table.

It turns out this is a novel behavior that does not happen with
PyPDF2 version used by vanilla Odoo 14 which is 1.26.0.

The upstream commit 07297fb has
updated the test PDF file (odoo/addons/base/tests/minimal.pdf) for
which the mentioned xref exception is not raised anymore.

For the backport, the test case test_download_one_corrupted_pdf
also had to be adapted a little bit.
  • Loading branch information
borna-ng committed Oct 15, 2024
1 parent 112880f commit 45f450f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Binary file modified odoo/addons/base/tests/minimal.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions odoo/addons/base/tests/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def test_download_one_corrupted_pdf(self):
"""
attach_name = 'super_attach.pdf'
# we need to corrupt the file: change count object in the xref table
pattern = re.compile(r"xref\n\d\s+(\d)")
corrupted_file = re.sub(pattern, "xref\n0 5", self.file.decode('utf-8'), 1).encode('utf-8')
pattern = re.compile(rb"xref\n\d\s+(\d)")
corrupted_file = re.sub(pattern, b"xref\n0 5", self.file, 1)

self.env['ir.attachment'].create({
'datas': base64.b64encode(corrupted_file),
Expand Down

0 comments on commit 45f450f

Please sign in to comment.