From de5a38366c1e123acb52e60ff2e21abf7e09122b Mon Sep 17 00:00:00 2001 From: Kim Minh Kaplan Date: Sat, 17 Nov 2018 07:37:33 +0000 Subject: [PATCH] [BUGFIX] Expect a space after the "+" in Client::authenticate. RFC 3501: A continue-req from the server starts with "+" SP. --- src/client.rs | 4 ++-- src/parse.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index cfdebb8..4039f38 100644 --- a/src/client.rs +++ b/src/client.rs @@ -390,7 +390,7 @@ impl Client { // early (see also comment on `login`) ok_or_unauth_client_err!(self.readline(&mut line), self); - if line.starts_with(b"+") { + if line.starts_with(b"+ ") { let data = ok_or_unauth_client_err!( parse_authenticate_response(String::from_utf8(line).unwrap()), self @@ -947,7 +947,7 @@ mod tests { #[test] fn authenticate() { - let response = b"+YmFy\r\n\ + let response = b"+ YmFy\r\n\ a1 OK Logged in\r\n".to_vec(); let command = "a1 AUTHENTICATE PLAIN\r\n\ Zm9v\r\n"; diff --git a/src/parse.rs b/src/parse.rs index f198b46..262f1ae 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -7,7 +7,7 @@ use super::error::{Error, ParseError, Result}; use super::types::*; pub fn parse_authenticate_response(line: String) -> Result { - let authenticate_regex = Regex::new("^\\+(.*)\r\n").unwrap(); + let authenticate_regex = Regex::new("^\\+ (.*)\r\n").unwrap(); if let Some(cap) = authenticate_regex.captures_iter(line.as_str()).next() { let data = cap.get(1).map(|x| x.as_str()).unwrap_or("");