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 aaryn.startmail
Recipients aaryn.startmail, barry, r.david.murray
Date 2019-02-26.13:36:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551188171.92.0.209402292964.issue36041@roundup.psfhosted.org>
In-reply-to
Content
Although I am not personally interested in backporting a fix for this issue, anyone that experiences this issue in python 3.5 can execute the following monkey patch to solve the issue:

def _fix_issue_36041_3_5():
    from email._header_value_parser import QuotedString, ValueTerminal, quote_string
    import email._header_value_parser

    class BareQuotedString(QuotedString):

        token_type = 'bare-quoted-string'

        def __str__(self):
            return quote_string(''.join(str(x) for x in self))

        @property
        def value(self):
            return ''.join(str(x) for x in self)

        @property
        def parts(self):
            parts = list(self)
            escaped_parts = []
            for part in parts:
                if isinstance(part, ValueTerminal):
                    escaped = quote_string(str(part))[1:-1]
                    escaped_parts.append(ValueTerminal(escaped, 'ptext'))
                else:
                    escaped_parts.append(part)
            # Add quotes to the first and last parts.
            escaped_parts[0] = ValueTerminal('"' + str(escaped_parts[0]), 'ptext')
            escaped_parts[-1] = ValueTerminal(str(escaped_parts[-1] + '"'), 'ptext')
            return escaped_parts

    email._header_value_parser.BareQuotedString = BareQuotedString
History
Date User Action Args
2019-02-26 13:36:11aaryn.startmailsetrecipients: + aaryn.startmail, barry, r.david.murray
2019-02-26 13:36:11aaryn.startmailsetmessageid: <1551188171.92.0.209402292964.issue36041@roundup.psfhosted.org>
2019-02-26 13:36:11aaryn.startmaillinkissue36041 messages
2019-02-26 13:36:11aaryn.startmailcreate