[FIX] account: adopt unexpected string while upload

This issue occurs while uploading a PDF file and that PDF file has an unexpected
string. So, The trackback will appear.

Step reproduce :
- install the account_accountant Module
- Open Accounting Module
- Click On Customer > Invoices
- Click On Upload Button > Upload PDF file

Error:
Unexpected escaped string: b'~'

When a user uploads a PDF file, PyPDF2 does not recognise the symbol
and character combination as a valid escape sequence, such as (\), (~).

sentry-4304111635

closes odoo/odoo#129556

X-original-commit: ea150a6f4be44ffc6f15837d5febd06fa1b695be
Signed-off-by: John Laterre (jol) <jol@odoo.com>
This commit is contained in:
Sanket Brahmbhatt
2023-07-25 21:22:38 +02:00
parent ddd7772abc
commit bdceb080a9
+2 -1
View File
@@ -4,6 +4,7 @@ from odoo.tools.pdf import OdooPdfFileReader
from lxml import etree
from struct import error as StructError
from PyPDF2.utils import PdfReadError
import io
import logging
@@ -57,7 +58,7 @@ class IrAttachment(models.Model):
try:
for xml_name, xml_content in pdf_reader.getAttachments():
to_process.extend(self._decode_edi_xml(xml_name, xml_content))
except (NotImplementedError, StructError) as e:
except (NotImplementedError, StructError, PdfReadError) as e:
_logger.warning("Unable to access the attachments of %s. Tried to decrypt it, but %s.", filename, e)
# Process the pdf itself.