Skip to content

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

Closed
fw-bot wants to merge 1 commit intoodoo:saas-17.4from
odoo-dev:saas-17.4-17.0-fix-pdf-compatibility-shims-moc-0vnq-fw
Closed

[FW][FIX] tools: fix PdfFileReader overwrite#188195
fw-bot wants to merge 1 commit intoodoo:saas-17.4from
odoo-dev:saas-17.4-17.0-fix-pdf-compatibility-shims-moc-0vnq-fw

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Nov 22, 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: #187900

@robodoo
Copy link
Contributor

robodoo commented Nov 22, 2024

Pull request status dashboard

@robodoo robodoo added forwardport This PR was created by @fw-bot conflict There was an error while creating this forward-port PR labels Nov 22, 2024
@fw-bot
Copy link
Contributor Author

fw-bot commented Nov 22, 2024

@d-fence @xmo-odoo cherrypicking of pull request #187900 failed.

stdout:

Auto-merging odoo/tools/pdf/_pypdf2_1.py
CONFLICT (content): Merge conflict in odoo/tools/pdf/_pypdf2_1.py

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

⚠️ after resolving this conflict, you will need to merge it via @robodoo.

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

@C3POdoo C3POdoo added the RD research & development, internal work label Nov 22, 2024
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)
@d-fence d-fence force-pushed the saas-17.4-17.0-fix-pdf-compatibility-shims-moc-0vnq-fw branch from 7f3f8ac to 6214c7c Compare November 22, 2024 14:57
@C3POdoo C3POdoo requested a review from a team November 22, 2024 14:59
@xmo-odoo
Copy link
Collaborator

@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 #188195

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
@robodoo robodoo closed this Nov 25, 2024
@d-fence d-fence deleted the saas-17.4-17.0-fix-pdf-compatibility-shims-moc-0vnq-fw branch November 27, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflict There was an error while creating this forward-port PR 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.

5 participants