gmail IMAP extensions are returned as MIME encoded-words

Dave Jagoda <[email protected]> Thu, 31 Dec 2020 08:04:43 -0800
Newsgroups gmane.mail.getmail.user
Message-ID <CAFne1W8sEBZbx1gTZH5sPEHp582SyU3FaEYKKkx_vSjkKg5F_w@mail.gmail.com>
Using getmail 5.15 to fetch messages with Google's IMAP extensions
currently returns data like this:

X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCIgJlRnQS0gJlZNRS0gc3lzdCZBT2ctbWVz?=
X-GMAIL-THRID: =?utf-8?q?1234567890123456789?=
X-GMAIL-MSGID: =?utf-8?q?1234567890123456789?=

Changing line 1635 of getmailcore/_retrieverbases.py from this:
    msg.add_header(header, value)
to this:
    msg.add_header(header, unicode(value))

Makes the output more closely match what you see using IMAP directly:

X-GMAIL-LABELS: "\\Sent" &TgA- &VME- syst&AOg-mes
X-GMAIL-THRID: 1234567890123456789
X-GMAIL-MSGID: 1234567890123456789

The 4 labels in this example are: \Sent, 一, 品, and systèmes and with this
modification are returned with their original IMAP UTF7 encodings. The
thread ID and message ID are now just returned as numbers.

Please consider making this change in the getmail source.

Thanks,
-dj