Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parsing adds whitespace to the front of long headers #124452

Closed
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestopic-emailtype-bugAn unexpected behavior, bug, or error
@calpaterson

Description

@calpaterson

Bug report

Bug description:

When parsing back a written email, whitespace seems to be prepended to the header if the header was wrapped upon writing.

This is particularly noticeable for message-ids, which end up different - with either a space or a newline prepended depending on what policy is set to (compat32: newline, default: space).

importstringfromemailimportmessage_from_bytesfromemail.messageimportEmailMessageimportemail.policyorig=EmailMessage()orig["Message-ID"]=string.ascii_lowercase*3policy=email.policy.default# changing to compat32 emits a different errorparsed=message_from_bytes(orig.as_bytes(policy=policy),policy=policy)assert (parsed["Message-ID"]==orig["Message-ID"]),f"message ids don't match: '{orig['Message-ID']}' != '{parsed['Message-ID']}'"

I'm not very familiar with RFC2822, but based on therules it includes for "long" header fields, the written email bytes look right to me, it's just when it's being read back it's not right.

CPython versions tested on:

3.9, 3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp