Skip to content

Commit

Permalink
fix(imap-proto): handle short continuation responses
Browse files Browse the repository at this point in the history
Fixes #67
  • Loading branch information
dignifiedquire authored and djc committed Dec 19, 2019
1 parent 2b8701b commit de42079
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion imap-proto/src/parser/rfc3501.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ named!(resp_text<(Option<ResponseCode>, Option<&str>)>, do_parse!(
));

named!(continue_req<Response>, do_parse!(
tag!("+ ") >>
tag!("+") >>
opt!(tag!(" ")) >> // Some servers do not send the space :/
text: resp_text >> // TODO: base64
tag!("\r\n") >>
(Response::Continue {
Expand Down Expand Up @@ -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)
}
}
}

0 comments on commit de42079

Please sign in to comment.