esabora: fix crash on empty document field (#70193)

This commit is contained in:
Agate 2022-10-13 10:14:06 +02:00
parent 0d39325ef4
commit 5eae2a1a29
2 changed files with 3 additions and 1 deletions

View File

@ -174,7 +174,7 @@ def populate_document_field(field, value):
# let's compute their size in bytes based on the base64 payload (without = padding)
# cf https://stackoverflow.com/a/45401395/2844093
for f in value:
if not value:
if not f:
continue
size = (len(f['content']) * 3) / 4 - f['content'].count('=', -2)
field['fieldValue'].append(

View File

@ -101,6 +101,8 @@ def test_do_treatment(app, connector):
'content_type': 'application/pdf',
'content': base64.b64encode(file_content2).decode(),
},
# empty field, will be skipped
'PJ_Documents/2': "",
# ensure we handle single documents as well
'PJ_Documents_Autre': {
'filename': 'test3.pdf',