Skip to content

get_body() is not robust to LF line endings #22

@link2xt

Description

@link2xt

Current code of get_body expects that body starts after <CR><LF><CR><LF>:

Ok(bytes::get_all_after(email.raw_bytes, b"\r\n\r\n").to_vec())

This code does not work for mails extracted from Dovecot Maildir which have LF line endings.

mailparse already splits headers and body in a different way inside parse_headers function:
https://github.com/staktrace/mailparse/blob/c51e92416c193072c739035fdcd5501c15f690e4/src/lib.rs#L939C1-L952C7

I managed to verify signatures of mails from Maildir, but had to do .replace("\n", "\r\n").

It would be nice to reuse mailparse splitting instead of splitting in a non-robust way. mailparse currently does not expose body_bytes (and header_bytes) fields, but proposing this to https://github.com/staktrace/mailparse/ is easy as it is well-maintained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions