This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bryced
Recipients barry, bryced, r.david.murray
Date 2018-10-03.07:06:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538550388.79.0.545547206417.issue34881@psf.upfronthosting.co.za>
In-reply-to
Content
Since Python 3.6.4 folding of unstructured headers uses the encoded words syntax even if there are no special characters.  

This makes DKIM-Signature headers that are unreadable to google's gmail servers. It may be that encoded-words are not valid in this header.  I don't see them mentioned here: https://tools.ietf.org/html/rfc6376#page-8

Here is the smallest test case I could create to demonstrate the issue.

One solution would be to add DKIM-Signature to the HeaderRegistry but I'm not yet expert enough to execute this. I went down that path for a few hours. Didn't see a straight-forward way to disable encoded words.

Setting EmailPolicy(max_line_length=None) does output without encoded words but I worry that will cause different incompatibility issues.


from email.headerregistry import HeaderRegistry
from email.policy import SMTP

def test_unstructured_encoded_word_folding():
    header = HeaderRegistry()('DKIM-Signature', 'a' * 85)
    folded = header.fold(policy=SMTP.clone(refold_source=None))
    print(f'\nDKIM-Signature: {header}')
    print(folded)
    assert '=?utf-8?q?' not in folded


Output:

DKIM-Signature: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
DKIM-Signature: =?utf-8?q?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?=
 =?utf-8?q?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?=

AssertionError()!
History
Date User Action Args
2018-10-03 07:06:28brycedsetrecipients: + bryced, barry, r.david.murray
2018-10-03 07:06:28brycedsetmessageid: <1538550388.79.0.545547206417.issue34881@psf.upfronthosting.co.za>
2018-10-03 07:06:28brycedlinkissue34881 messages
2018-10-03 07:06:28brycedcreate