mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-25 17:33:08 +01:00
Patch for handling base64 encoding on Py 2 and 3, to address #567
This commit is contained in:
parent
43035afc07
commit
32cc5e2496
@ -356,10 +356,15 @@ def ticket_from_message(message, queue, logger):
|
|||||||
if isinstance(payload, list):
|
if isinstance(payload, list):
|
||||||
payload = payload.pop().as_string()
|
payload = payload.pop().as_string()
|
||||||
payloadToWrite = payload
|
payloadToWrite = payload
|
||||||
|
# check version of python to ensure use of only the correct error type
|
||||||
|
if six.PY2:
|
||||||
|
non_b64_err = binascii.Error
|
||||||
|
else:
|
||||||
|
non_b64_err = TypeError
|
||||||
try:
|
try:
|
||||||
logger.debug("Try to base64 decode the attachment payload")
|
logger.debug("Try to base64 decode the attachment payload")
|
||||||
payloadToWrite = base64.decodestring(payload)
|
payloadToWrite = base64.decodestring(payload)
|
||||||
except (binascii.Error, TypeError):
|
except non_b64_err:
|
||||||
logger.debug("Payload was not base64 encoded, using raw bytes")
|
logger.debug("Payload was not base64 encoded, using raw bytes")
|
||||||
payloadToWrite = payload
|
payloadToWrite = payload
|
||||||
files.append(SimpleUploadedFile(name, part.get_payload(decode=True), mimetypes.guess_type(name)[0]))
|
files.append(SimpleUploadedFile(name, part.get_payload(decode=True), mimetypes.guess_type(name)[0]))
|
||||||
|
Loading…
Reference in New Issue
Block a user