GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — email: a header value that is itself a well-formed RFC 2047 encoded word is decoded or written verbatim, never encoded · Issue #160148 · python/cpython Open Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug descriptionWith the modern ( >>> import email.message, email.policy >>> m = email.message.EmailMessage() >>> m['Subject'] = '=?utf-8?q?x?=' >>> m['Subject'] 'x' >>> m.as_string() 'Subject: x\n\n' >>> email.policy.default.fold('Subject', '=?utf-8?q?x?=') 'Subject: =?utf-8?q?x?=\n' # a reader decodes this to 'x' as well >>> email.policy.default.fold('Subject', '=?utf-8?q?x?=\xe9') 'Subject: x=?utf-8?q?=C3=A9?=\n' The legacy API gets this right: >>> import email.header >>> email.header.Header('=?utf-8?q?x?=', 'utf-8').encode() '=?utf-8?b?PT91dGYtOD9xP3g/PQ==?=' RFC 2047 §7 says that a composer "MUST ensure that any string of non-white-space printable ASCII characters within a Apparently both behaviors follow the current documentation, so I guess this needs some discussion. Possible directions, none of which I have a strong opinion on:
This came out of the Hypothesis round-trip test in #159771, which originally carried it as an @hypothesis.given( word=hypothesis.strategies.text(alphabet='abc', min_size=1, max_size=5), trailer=hypothesis.strategies.sampled_from(['', ')', ' word']), ) @hypothesis.example(word='x', trailer='') @hypothesis.example(word='x', trailer=')') def test_fold_encoded_word_lookalike_round_trip(self, word, trailer): subject = f'=?utf-8?q?{word}?={trailer}' folded = email.policy.default.fold('Subject', subject) reparsed = email.message_from_string( folded, policy=email.policy.default)['Subject'] self.assertEqual(reparsed, subject) Possibly related: #85725 (an encoded word produced by folding that violates RFC 2047), though that is about the generator's output rather than user text. CPython versions tested onCPython main (6e1bd24) Operating systems tested onLinux Activity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |