Skip to content

[FW][FIX] tools: fix PdfFileReader overwrite#188394

Closed
fw-bot wants to merge 1 commit intoodoo:masterfrom
odoo-dev:master-17.0-fix-pdf-compatibility-shims-moc-YmMM-fw
Closed

[FW][FIX] tools: fix PdfFileReader overwrite#188394
fw-bot wants to merge 1 commit intoodoo:masterfrom
odoo-dev:master-17.0-fix-pdf-compatibility-shims-moc-YmMM-fw

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Nov 25, 2024

In #183165 the override of the PdfReader constructor was forcing the strict parameter to True1 in the pdf shim for PyPDF2 1.x.

So, when a PdfReader is instanciated with strict set to False, with that PyPDF version installed, the strict parameter is not taken into account. In that case, it impossible to upload some PDF documents that were allowed before the shims.

With this commit, the override of the constructor is removed in the 1.x shim and the PdfReader override is only made once at the upper level. The strict parameter is defaulting to True but not enforced as it was the default behavior in PyPDF2 1.x. It should be changed later to follow the behavior of PyPDF2 >= 2.x.

Also, any other parameter of the constructor are discarded as they are useless in PyPDF 1.x and not compatible at all with PyPDF >= 2.x. On the other hand, the new password parameter of 2.x is not backward compatible.

Forward-Port-Of: #188195
Forward-Port-Of: #187900

In odoo#183165 the override of the PdfReader constructor was forcing the
`strict` parameter to True [1] in the pdf shim for PyPDF2 1.x.

So, when a PdfReader is instanciated with strict set to False, with that
PyPDF version installed, the strict parameter is not taken into account.
In that case, it impossible to upload some PDF documents that were
allowed before the shims.

With this commit, the override of the constructor is removed in the 1.x
shim and the PdfReader override is only made once at the upper level.
The `strict` parameter is defaulting to True but not enforced as it was
the default behavior in PyPDF2 1.x. It should be changed later to follow
the behavior of PyPDF2 >= 2.x.

Also, any other parameter of the constructor are discarded as they are
useless in PyPDF 1.x and not compatible at all with PyPDF >= 2.x. On the
other hand, the new `password` parameter of 2.x is not backward compatible.

[1](odoo/odoo@f03a12c/odoo/tools/pdf/_pypdf2_1.py#L19)

X-original-commit: d5473ce
@robodoo
Copy link
Contributor

robodoo commented Nov 25, 2024

Pull request status dashboard

@fw-bot
Copy link
Contributor Author

fw-bot commented Nov 25, 2024

@d-fence @xmo-odoo this PR targets master and is the last of the forward-port chain containing:

To merge the full chain, use

@robodoo r+

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Nov 25, 2024
@C3POdoo C3POdoo added the RD research & development, internal work label Nov 25, 2024
@d-fence
Copy link
Contributor

d-fence commented Nov 25, 2024

robodoo r+

robodoo pushed a commit that referenced this pull request Nov 25, 2024
In #183165 the override of the PdfReader constructor was forcing the
`strict` parameter to True [1] in the pdf shim for PyPDF2 1.x.

So, when a PdfReader is instanciated with strict set to False, with that
PyPDF version installed, the strict parameter is not taken into account.
In that case, it impossible to upload some PDF documents that were
allowed before the shims.

With this commit, the override of the constructor is removed in the 1.x
shim and the PdfReader override is only made once at the upper level.
The `strict` parameter is defaulting to True but not enforced as it was
the default behavior in PyPDF2 1.x. It should be changed later to follow
the behavior of PyPDF2 >= 2.x.

Also, any other parameter of the constructor are discarded as they are
useless in PyPDF 1.x and not compatible at all with PyPDF >= 2.x. On the
other hand, the new `password` parameter of 2.x is not backward compatible.

[1](f03a12c/odoo/tools/pdf/_pypdf2_1.py#L19)

closes #188394

X-original-commit: d5473ce
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
@robodoo robodoo added the 18.1 label Nov 25, 2024
@robodoo robodoo closed this Nov 25, 2024
@d-fence d-fence deleted the master-17.0-fix-pdf-compatibility-shims-moc-YmMM-fw branch November 27, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

18.1 forwardport This PR was created by @fw-bot RD research & development, internal work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants