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():