mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-10-09 12:05:49 +08:00
IMAP LIST-STATUS (RFC 5819) returns items in wrong order (fixes #1129)
This commit is contained in:
parent
14e3b3a852
commit
b39d807600
1 changed files with 29 additions and 15 deletions
|
@ -150,15 +150,15 @@ impl TryFrom<&str> for Attribute {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||||
match value {
|
hashify::tiny_map!(value.as_bytes(),
|
||||||
"archive" => Ok(Attribute::Archive),
|
"archive" => Attribute::Archive,
|
||||||
"drafts" => Ok(Attribute::Drafts),
|
"drafts" => Attribute::Drafts,
|
||||||
"junk" => Ok(Attribute::Junk),
|
"junk" => Attribute::Junk,
|
||||||
"sent" => Ok(Attribute::Sent),
|
"sent" => Attribute::Sent,
|
||||||
"trash" => Ok(Attribute::Trash),
|
"trash" => Attribute::Trash,
|
||||||
"important" => Ok(Attribute::Important),
|
"important" => Attribute::Important,
|
||||||
_ => Err(()),
|
)
|
||||||
}
|
.ok_or(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,13 +249,27 @@ impl ImapResponse for Response {
|
||||||
fn serialize(self) -> Vec<u8> {
|
fn serialize(self) -> Vec<u8> {
|
||||||
let mut buf = Vec::with_capacity(100);
|
let mut buf = Vec::with_capacity(100);
|
||||||
|
|
||||||
for list_item in &self.list_items {
|
match (self.list_items.is_empty(), self.status_items.is_empty()) {
|
||||||
list_item.serialize(&mut buf, self.is_rev2, self.is_lsub);
|
(false, false) => {
|
||||||
|
for (list_item, status_item) in self.list_items.iter().zip(self.status_items.iter())
|
||||||
|
{
|
||||||
|
list_item.serialize(&mut buf, self.is_rev2, self.is_lsub);
|
||||||
|
status_item.serialize(&mut buf, self.is_rev2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(false, true) => {
|
||||||
|
for list_item in &self.list_items {
|
||||||
|
list_item.serialize(&mut buf, self.is_rev2, self.is_lsub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(true, false) => {
|
||||||
|
for status_item in &self.status_items {
|
||||||
|
status_item.serialize(&mut buf, self.is_rev2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
for status_item in &self.status_items {
|
|
||||||
status_item.serialize(&mut buf, self.is_rev2);
|
|
||||||
}
|
|
||||||
buf
|
buf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,8 +379,8 @@ mod tests {
|
||||||
};
|
};
|
||||||
let expected_v2 = concat!(
|
let expected_v2 = concat!(
|
||||||
"* LIST (\\Subscribed) \"/\" \"INBOX\"\r\n",
|
"* LIST (\\Subscribed) \"/\" \"INBOX\"\r\n",
|
||||||
"* LIST () \"/\" \"foo\" (\"CHILDINFO\" (\"SUBSCRIBED\"))\r\n",
|
|
||||||
"* STATUS \"INBOX\" (MESSAGES 17)\r\n",
|
"* STATUS \"INBOX\" (MESSAGES 17)\r\n",
|
||||||
|
"* LIST () \"/\" \"foo\" (\"CHILDINFO\" (\"SUBSCRIBED\"))\r\n",
|
||||||
"* STATUS \"foo\" (MESSAGES 30 UNSEEN 29)\r\n",
|
"* STATUS \"foo\" (MESSAGES 30 UNSEEN 29)\r\n",
|
||||||
);
|
);
|
||||||
let expected_v1 = concat!(
|
let expected_v1 = concat!(
|
||||||
|
|
Loading…
Add table
Reference in a new issue