From 35feffd7023037757c93d81518cb8b577a937e3c Mon Sep 17 00:00:00 2001 From: LeandroJatai Date: Wed, 19 Jun 2024 10:20:23 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20elimina=20dupla=20extra=C3=A7=C3=A3o=20d?= =?UTF-8?q?e=20assinaturas=20eletr=C3=B4nicas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/receivers.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sapl/base/receivers.py b/sapl/base/receivers.py index 4f5c052f5..8b6da9b95 100644 --- a/sapl/base/receivers.py +++ b/sapl/base/receivers.py @@ -283,13 +283,18 @@ def signed_files_extraction_function(sender, instance, **kwargs): return signs # tenta extrair via /Fields + fields_br = [] try: pdf = PdfFileReader(file) fields = pdf.getFields() + fields_br = list( + map(lambda x: x.get('/V', {}).get('/ByteRange', []), fields.values())) except Exception as e: try: pdf = PdfFileReader(file, strict=False) fields = pdf.getFields() + fields_br = list( + map(lambda x: x.get('/V', {}).get('/ByteRange', []), fields.values())) except Exception as ee: fields = ee @@ -309,13 +314,17 @@ def signed_files_extraction_function(sender, instance, **kwargs): n += 1 br = [int(i, 10) for i in pdfdata[start + 1: stop].split()] + + # if br in fields_br: + # continue + contents = pdfdata[br[0] + br[1] + 1: br[2] - 1] bcontents = bytes.fromhex(contents.decode("utf8")) data1 = pdfdata[br[0]: br[0] + br[1]] data2 = pdfdata[br[2]: br[2] + br[3]] #signedData = data1 + data2 - nome = 'Nome do assinante não localizado.' + not_nome = nome = 'Nome do assinante não localizado.' oname = '' try: info = cms.ContentInfo.load(bcontents) @@ -348,7 +357,8 @@ def signed_files_extraction_function(sender, instance, **kwargs): pass fd = None - signs.append((nome, [fd, oname])) + if nome != not_nome: + signs.append((nome, [fd, oname])) except Exception as e: pass