From de420791b4e240242592616938407b742454c46c Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 19 Dec 2019 15:13:01 +0100 Subject: [PATCH] fix(imap-proto): handle short continuation responses Fixes #67 --- imap-proto/src/parser/rfc3501.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/imap-proto/src/parser/rfc3501.rs b/imap-proto/src/parser/rfc3501.rs index 922823d..42075e8 100644 --- a/imap-proto/src/parser/rfc3501.rs +++ b/imap-proto/src/parser/rfc3501.rs @@ -471,7 +471,8 @@ named!(resp_text<(Option, Option<&str>)>, do_parse!( )); named!(continue_req, do_parse!( - tag!("+ ") >> + tag!("+") >> + opt!(tag!(" ")) >> // Some servers do not send the space :/ text: resp_text >> // TODO: base64 tag!("\r\n") >> (Response::Continue { @@ -837,4 +838,25 @@ mod tests { rsp => panic!("should be incomplete: {:?}", rsp), } } + + #[test] + fn test_continuation() { + // regular RFC compliant + match parse_response(b"+ \r\n") { + Ok((_, Response::Continue { + code: None, + information: None, + })) => {} + rsp @ _ => panic!("unexpected response {:?}", rsp) + } + + // short version, sent by yandex + match parse_response(b"+\r\n") { + Ok((_, Response::Continue { + code: None, + information: None, + })) => {} + rsp @ _ => panic!("unexpected response {:?}", rsp) + } + } }