From e98d493faea42bdb732677a6b41a15e435e65a26 Mon Sep 17 00:00:00 2001 From: Gabriel Balog Date: Thu, 8 Feb 2018 11:01:04 -0200 Subject: [PATCH] 3: Auto stash before merge of "master3" and "origin/master3" --- pytrustnfe/utils.py | 2 ++ pytrustnfe/xml/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pytrustnfe/utils.py b/pytrustnfe/utils.py index b53ba37..40cc12e 100644 --- a/pytrustnfe/utils.py +++ b/pytrustnfe/utils.py @@ -85,6 +85,8 @@ def _find_node(xml, node): def gerar_nfeproc(envio, recibo): NSMAP = {None: 'http://www.portalfiscal.inf.br/nfe'} root = ET.Element("nfeProc", versao="3.10", nsmap=NSMAP) + if 'encoding="utf-8"' in recibo: + recibo = re.sub('encoding="utf-8"', '', recibo) docEnvio = ET.fromstring(envio) docRecibo = ET.fromstring(recibo) diff --git a/pytrustnfe/xml/__init__.py b/pytrustnfe/xml/__init__.py index 5a848b2..89279e9 100644 --- a/pytrustnfe/xml/__init__.py +++ b/pytrustnfe/xml/__init__.py @@ -58,7 +58,8 @@ def render_xml(path, template_name, remove_empty, **nfe): def sanitize_response(response): - response = re.sub('encoding="UTF-8"', '', response) + if 'encoding="utf-8"' in response or 'encoding="UTF-8"' in response: + response = re.sub('encoding="UTF-8"', '', response) tree = etree.fromstring(response) # Remove namespaces inuteis na resposta for elem in tree.getiterator():