From 8bfe61d767209585b47d4c6e4344387fc01d4098 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 8 Jul 2022 16:52:17 +0200 Subject: [PATCH] Count lines the same way as Dovecot+Cyrus --- src/imap/mailbox_view.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs index bffcd9b..c687f66 100644 --- a/src/imap/mailbox_view.rs +++ b/src/imap/mailbox_view.rs @@ -568,7 +568,10 @@ fn build_imap_email_struct<'a>( specific: SpecificFields::Text { subtype, number_of_lines: u32::try_from( - Cursor::new(bp.body_raw.as_ref()).lines().count(), + // We do not count the number of lines but the number of line + // feeds to have the same behavior as Dovecot and Cyrus. + // 2 lines = 1 line feed. + bp.body_raw.as_ref().iter().filter(|&c| c == &b'\n').count(), )?, }, },