Skip to content
Snippets Groups Projects
Commit c4028156 authored by Nasreddin Boulif (bon)'s avatar Nasreddin Boulif (bon)
Browse files

[FIX] account_edi: enable to parse XML facturx in mail


Issue:

  When receiving a mail with a facturx XML file as attachment,
  the datas in the XML files are not parsed.

Cause:

  For security reason, if a mail attachment is a XML file, it will
  be saved as plain text and therefore not be parsed.

Solution:

  If attachment mimetype is `plain/text` and content starts with
  `<?xml`, consider attachment as XML for the parsing.

opw-2655445

closes odoo/odoo#91196

Signed-off-by: default avatarWilliam André (wan) <wan@odoo.com>
parent 7422207c
No related branches found
No related tags found
No related merge requests found
......@@ -428,9 +428,12 @@ class AccountEdiFormat(models.Model):
content = base64.b64decode(attachment.with_context(bin_size=False).datas)
to_process = []
# XML attachments received by mail have a 'text/plain' mimetype.
# Therefore, if content start with '<?xml', it is considered as XML.
is_text_plain_xml = 'text/plain' in attachment.mimetype and content.startswith(b'<?xml')
if 'pdf' in attachment.mimetype:
to_process.extend(self._decode_pdf(attachment.name, content))
elif 'xml' in attachment.mimetype:
elif 'xml' in attachment.mimetype or is_text_plain_xml:
to_process.extend(self._decode_xml(attachment.name, content))
else:
to_process.extend(self._decode_binary(attachment.name, content))
......
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