From 3268abf0d1e2cfd88eafc3272d8e3b84a43769e2 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 3 Apr 2020 13:20:58 +0200 Subject: [PATCH] Fix rendering of attachments and raw messages It seems older django implicitly added a bytes() around bytea fields returned from psycopg2. The actual change happened around the python3 move, but django painted over the differences so we didn't realize it needed to be changed. --- django/archives/mailarchives/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/archives/mailarchives/views.py b/django/archives/mailarchives/views.py index 4a5729c..82e8cef 100644 --- a/django/archives/mailarchives/views.py +++ b/django/archives/mailarchives/views.py @@ -383,7 +383,7 @@ def attachment(request, attid): ensure_message_permissions(request, r[0][2]) - return HttpResponse(r[0][3], content_type=r[0][1]) + return HttpResponse(bytes(r[0][3]), content_type=r[0][1]) def _build_thread_structure(threadid): @@ -544,7 +544,7 @@ def message_raw(request, msgid): if row[0][1]: r = HttpResponse('This message has been hidden.', content_type='text/plain') else: - r = HttpResponse(row[0][2], content_type='text/plain') + r = HttpResponse(bytes(row[0][2]), content_type='text/plain') if settings.PUBLIC_ARCHIVES: r['xkey'] = 'pgat_{0}'.format(row[0][0]) return r -- 2.39.5