Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
link2xt opened this issue Jan 18, 2024 · 0 comments
Open

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

link2xt opened this issue Jan 18, 2024 · 0 comments

Comments

@link2xt
Copy link

link2xt commented Jan 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant