Skip to content

Commit

Permalink
Merge pull request #98 from kmkaplan/issue-95-authenticate-base64
Browse files Browse the repository at this point in the history
[BUGFIX] Expect a space after the "+" in Client::authenticate.
  • Loading branch information
jonhoo authored Nov 17, 2018
2 parents 28e4201 + de5a383 commit bddfab3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<T: Read + Write> Client<T> {
// 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
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::error::{Error, ParseError, Result};
use super::types::*;

pub fn parse_authenticate_response(line: String) -> Result<String> {
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("");
Expand Down

0 comments on commit bddfab3

Please sign in to comment.