Fix rendering of attachments and raw messages
authorMagnus Hagander <magnus@hagander.net>
Fri, 3 Apr 2020 11:20:58 +0000 (13:20 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 3 Apr 2020 11:23:43 +0000 (13:23 +0200)
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

index 4a5729cd389aeb56368c54d4ab16a12dcc68f32d..82e8cef9cedb773d5d99eb9501fdb95c5fca301b 100644 (file)
@@ -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