Package: nm.debian.org Severity: normal Tags: patch On mail archive summary pages, like https://nm.debian.org/am/display-mail-archive/nirgal, email headers are not decoded and thus sometimes are unreadable. My page shows on Sun, 11 Jan 2015 22:17:38 +0000 a message from "=?UTF-8?B?SmVhbi1NaWNoZWwgTmlyZ2FsIFZvdXJnw6hyZQ==?= <jmv_...@nirgal.com>" with subject "=?UTF-8?B?UmU6IEFib3V0IHlvdXIgRGViaWFuIE5NIGFwcGxpY2F0aW9uIChKZWE=?= =?UTF-8?B?bi1NaWNoZWwgVm91cmfDqHJlKQ==?=".
You must to be logged in to access it. Attached is a patch that decode the mbox headers. -- System Information: Debian Release: 8.0 APT prefers testing APT policy: (990, 'testing') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores) Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init)
diff --git a/backend/email.py b/backend/email.py index c127a25..4ed2a7c 100644 --- a/backend/email.py +++ b/backend/email.py @@ -101,6 +101,10 @@ def send_nonce(template_name, person, nonce=None, encrypted_nonce=None): def get_mbox_as_dicts(filename): try: ## we are reading, have not to flush with close for message in mailbox.mbox(filename, create=False): - yield dict(Body=message.get_payload(), **dict(message)) + msg_dict = {'Body': message.get_payload()} + for hkey, hval in message.items(): + hval, hencode = email.header.decode_header(hval)[0] + msg_dict[hkey] = unicode(hval, encoding=hencode or 'utf-8', errors='replace') + yield msg_dict except mailbox.NoSuchMailboxError: return
signature.asc
Description: OpenPGP digital signature