catch binascii.Error when decoding base64 (#39533)

This commit is contained in:
Emmanuel Cazenave 2020-02-04 17:23:20 +01:00
parent 5b788a5dff
commit 87c7468ab1
1 changed files with 3 additions and 2 deletions

View File

@ -21,6 +21,7 @@
"""Models for this connector module.""" # pylint: disable=too-many-lines
import base64
import binascii
import datetime
import json
import os
@ -800,7 +801,7 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# decode the recepisse from base 64
try:
base64.b64decode(recepisse['b64_content'])
except TypeError:
except (TypeError, binascii.Error):
raise APIError('Failed to decode recepisse content from base 64')
self.logger.debug("Successfully decoded recepisse from base 64")
@ -1040,7 +1041,7 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# decode the courrier from base 64
try:
base64.b64decode(courrier['b64_content'])
except TypeError:
except (TypeError, binascii.Error):
raise APIError('Failed to decode courrier content from base 64')
# return the 'courrier' file