fix second gmail case

This commit is contained in:
Michael Zhang 2021-08-26 17:20:21 -05:00
parent 77f0184276
commit c2002a06e5
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
2 changed files with 12 additions and 4 deletions

View file

@ -340,9 +340,10 @@ pub(crate) fn is_resp_specials(c: u8) -> bool { c == b']' }
rule!(pub resp_specials : u8 => satisfy(is_resp_specials)); rule!(pub resp_specials : u8 => satisfy(is_resp_specials));
rule!(pub resp_text : ResponseText => alt(( rule!(pub resp_text : ResponseText => alt((
// FUCK YOU GMAIL map(pair(
map(delimited(byte(b'['), resp_text_code, byte(b']')), delimited(byte(b'['), resp_text_code, byte(b']')),
|code| ResponseText { code: Some(code), info: Bytes::from(b"") }), opt(preceded(SP, text)),
), |(code, info)| ResponseText { code: Some(code), info: info.unwrap_or_else(|| Bytes::from(b"")) }),
map(pair( map(pair(
opt(terminated(delimited(byte(b'['), resp_text_code, byte(b']')), SP)), opt(terminated(delimited(byte(b'['), resp_text_code, byte(b']')), SP)),

View file

@ -102,7 +102,6 @@ fn test_gmail_is_shit() {
let res = response(Bytes::from(b"* OK [HIGHESTMODSEQ 694968]\r\n")) let res = response(Bytes::from(b"* OK [HIGHESTMODSEQ 694968]\r\n"))
.unwrap() .unwrap()
.1; .1;
eprintln!("{:?}", res);
assert!(matches!(res, assert!(matches!(res,
Response::Condition(Condition { Response::Condition(Condition {
status: Status::Ok, status: Status::Ok,
@ -111,4 +110,12 @@ fn test_gmail_is_shit() {
}) })
if c == Bytes::from(b"HIGHESTMODSEQ") && d == Bytes::from(b"694968") && e.is_empty() if c == Bytes::from(b"HIGHESTMODSEQ") && d == Bytes::from(b"694968") && e.is_empty()
)); ));
let res = resp_text(Bytes::from(b"[PERMANENTFLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen $NotPhishing $Phishing \\*)] Flags permitted.\r".to_vec())).unwrap().1;
eprintln!("{:?}", res);
eprintln!();
let res = response(Bytes::from(b"* OK [PERMANENTFLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen $NotPhishing $Phishing \\*)] Flags permitted.\r\n".to_vec())).unwrap().1;
eprintln!("{:?}", res);
assert!(matches!(res, Response::Condition(_)));
} }