Skip to content

mailbox.mbox.flush() corrupts caches message length in maildir / dovecot #137454

@TCHessen

Description

@TCHessen

Bug report

Bug description:

Hi,

in a python script I open a maildir, modify some message flags with add_flag() and update and flush the maildir again. The message files are named correctly, but the lenght of the files are wrong.

In my case I found the reason in two header lines.

"Content-Type: application/zip; " and "Content-Disposition: attachment; " contain a tailing space and that is removed when flushing the maildir.

The result is, that dovecote in the standard config throws an error. I know that there is a dovecot setting to ignore the caches size, but this is only a workaround and no real fix.

Broken physical size in mailbox Server/DMARC: read(/home/.../Maildir/.Server.DMARC/cur/1754216389.M736853P3583460.deb-vps2,S=5932,W=6025:2,FS) failed: Cached message size larger than expected (5932 > 5930, box=Server/DMARC, UID=6)

In my opinion update / flush must not modify the mailfile in any cases to prevent broken dkim signatures and this issue I explain.

with kind regards, TC

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions