From 38eff71971ae7b008782f172aa5b2ba3492e6017 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 18 Sep 2020 12:12:14 +0300 Subject: [PATCH] IMAP: don't show \Recent flag as tag Closes #74 --- melib/src/backends/imap/protocol_parser.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/melib/src/backends/imap/protocol_parser.rs b/melib/src/backends/imap/protocol_parser.rs index b4c5d6bed..c014bee16 100644 --- a/melib/src/backends/imap/protocol_parser.rs +++ b/melib/src/backends/imap/protocol_parser.rs @@ -1121,7 +1121,8 @@ pub fn flags(input: &[u8]) -> IResult<&[u8], (Flag, Vec)> { let mut input = input; while !input.starts_with(b")") && !input.is_empty() { - if input.starts_with(b"\\") { + let is_system_flag = input.starts_with(b"\\"); + if is_system_flag { input = &input[1..]; } let mut match_end = 0; @@ -1132,23 +1133,24 @@ pub fn flags(input: &[u8]) -> IResult<&[u8], (Flag, Vec)> { match_end += 1; } - match &input[..match_end] { - b"Answered" => { + match (is_system_flag, &input[..match_end]) { + (true, t) if t.eq_ignore_ascii_case(b"Answered") => { ret.set(Flag::REPLIED, true); } - b"Flagged" => { + (true, t) if t.eq_ignore_ascii_case(b"Flagged") => { ret.set(Flag::FLAGGED, true); } - b"Deleted" => { + (true, t) if t.eq_ignore_ascii_case(b"Deleted") => { ret.set(Flag::TRASHED, true); } - b"Seen" => { + (true, t) if t.eq_ignore_ascii_case(b"Seen") => { ret.set(Flag::SEEN, true); } - b"Draft" => { + (true, t) if t.eq_ignore_ascii_case(b"Draft") => { ret.set(Flag::DRAFT, true); } - f => { + (true, t) if t.eq_ignore_ascii_case(b"Recent") => { /* ignore */ } + (_, f) => { keywords.push(String::from_utf8_lossy(&f).into()); } }