Skip to content

Commit

Permalink
fix: allow whitespace at the end of ID response list
Browse files Browse the repository at this point in the history
https://archiveopteryx.org/ returns it in the `ID` response.
  • Loading branch information
link2xt authored and djc committed May 1, 2024
1 parent 730ee0e commit 0aeb02e
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions imap-proto/src/parser/rfc2971.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use std::{borrow::Cow, collections::HashMap};
use nom::{
branch::alt,
bytes::complete::tag_no_case,
character::complete::{char, space1},
character::complete::{char, space0, space1},
combinator::map,
multi::many0,
sequence::{separated_pair, tuple},
sequence::{preceded, separated_pair, tuple},
IResult,
};

Expand All @@ -38,7 +38,7 @@ fn id_param_list_not_nil(i: &[u8]) -> IResult<&[u8], HashMap<&str, &str>> {
char('('),
id_param,
many0(tuple((space1, id_param))),
char(')'),
preceded(space0, char(')')),
)),
|(_, first_param, rest_params, _)| {
let mut params = vec![first_param];
Expand Down Expand Up @@ -195,5 +195,23 @@ mod tests {
assert_eq!(id_info, None);
}
);

assert_matches!(
resp_id(br#"ID ("name" "Archiveopteryx" "version" "3.2.0" "compile-time" "Feb 6 2023 19:59:14" "homepage-url" "http://archiveopteryx.org" "release-url" "http://archiveopteryx.org/3.2.0" )"#),
Ok((_, Response::Id(Some(id_info)))) => {
assert_eq!(
id_info,
vec![
("name", "Archiveopteryx"),
("version", "3.2.0"),
("compile-time", "Feb 6 2023 19:59:14"),
("homepage-url", "http://archiveopteryx.org"),
("release-url", "http://archiveopteryx.org/3.2.0"),
].into_iter()
.map(|(k, v)| (Cow::Borrowed(k), Cow::Borrowed(v)))
.collect()
);
}
);
}
}

0 comments on commit 0aeb02e

Please sign in to comment.