Browse Source

fix: elimina dupla extração de assinaturas eletrônicas

pull/3723/head
LeandroJatai 6 months ago
parent
commit
35feffd702
  1. 12
      sapl/base/receivers.py

12
sapl/base/receivers.py

@ -283,13 +283,18 @@ def signed_files_extraction_function(sender, instance, **kwargs):
return signs return signs
# tenta extrair via /Fields # tenta extrair via /Fields
fields_br = []
try: try:
pdf = PdfFileReader(file) pdf = PdfFileReader(file)
fields = pdf.getFields() fields = pdf.getFields()
fields_br = list(
map(lambda x: x.get('/V', {}).get('/ByteRange', []), fields.values()))
except Exception as e: except Exception as e:
try: try:
pdf = PdfFileReader(file, strict=False) pdf = PdfFileReader(file, strict=False)
fields = pdf.getFields() fields = pdf.getFields()
fields_br = list(
map(lambda x: x.get('/V', {}).get('/ByteRange', []), fields.values()))
except Exception as ee: except Exception as ee:
fields = ee fields = ee
@ -309,13 +314,17 @@ def signed_files_extraction_function(sender, instance, **kwargs):
n += 1 n += 1
br = [int(i, 10) for i in pdfdata[start + 1: stop].split()] 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] contents = pdfdata[br[0] + br[1] + 1: br[2] - 1]
bcontents = bytes.fromhex(contents.decode("utf8")) bcontents = bytes.fromhex(contents.decode("utf8"))
data1 = pdfdata[br[0]: br[0] + br[1]] data1 = pdfdata[br[0]: br[0] + br[1]]
data2 = pdfdata[br[2]: br[2] + br[3]] data2 = pdfdata[br[2]: br[2] + br[3]]
#signedData = data1 + data2 #signedData = data1 + data2
nome = 'Nome do assinante não localizado.' not_nome = nome = 'Nome do assinante não localizado.'
oname = '' oname = ''
try: try:
info = cms.ContentInfo.load(bcontents) info = cms.ContentInfo.load(bcontents)
@ -348,6 +357,7 @@ def signed_files_extraction_function(sender, instance, **kwargs):
pass pass
fd = None fd = None
if nome != not_nome:
signs.append((nome, [fd, oname])) signs.append((nome, [fd, oname]))
except Exception as e: except Exception as e:

Loading…
Cancel
Save