Skip to content
Snippets Groups Projects
Commit 86935640 authored by Sanket Brahmbhatt's avatar Sanket Brahmbhatt
Browse files

[FIX] account_edi: 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#128072

Signed-off-by: default avatarJohn Laterre (jol) <jol@odoo.com>
parent ccc12cec
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ from odoo.tools.pdf import OdooPdfFileReader, OdooPdfFileWriter
from odoo.osv import expression
from odoo.tools import html_escape
from odoo.exceptions import RedirectWarning
from PyPDF2.utils import PdfReadError
from lxml import etree
from struct import error as StructError
......@@ -15,6 +16,7 @@ import logging
import pathlib
import re
_logger = logging.getLogger(__name__)
......@@ -394,7 +396,7 @@ class AccountEdiFormat(models.Model):
try:
for xml_name, content in pdf_reader.getAttachments():
to_process.extend(self._decode_xml(xml_name, 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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment