IMAP: Fix fetch responses (closes #2940) (credits to @markstos)
This commit is contained in:
@@ -138,9 +138,12 @@ pub fn test() {
|
||||
sections: sections.clone(),
|
||||
offset: None,
|
||||
contents: match contents {
|
||||
BodyContents::Bytes(_) => {
|
||||
BodyContents::Text("[binary content]".into())
|
||||
}
|
||||
BodyContents::Bytes(bytes) => BodyContents::Text(
|
||||
std::str::from_utf8(bytes.as_ref())
|
||||
.unwrap_or("[binary content]")
|
||||
.to_string()
|
||||
.into(),
|
||||
),
|
||||
text => text,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -71,18 +71,22 @@ pub async fn test(imap: &mut ImapConnection, _imap_check: &mut ImapConnection) {
|
||||
.await;
|
||||
imap.assert_read(Type::Tagged, ResponseType::Ok)
|
||||
.await
|
||||
.assert_contains("BINARY[1] {175}")
|
||||
.assert_contains("BINARY[1] ~{175}")
|
||||
.assert_contains("BINARY.SIZE[1] 175")
|
||||
.assert_contains("BODY[1.TEXT] {239}")
|
||||
.assert_contains("BODY[2.1.HEADER] {88}")
|
||||
.assert_contains("BINARY[2.1] {101}")
|
||||
.assert_contains("BINARY[2.1] ~{108}")
|
||||
.assert_contains("BODY[MIME] {54}")
|
||||
.assert_contains("BODY[HEADER.FIELDS (FROM)]<10> {8}")
|
||||
.assert_contains("“exporting”")
|
||||
.assert_contains("PGh0bWw+PHA+")
|
||||
.assert_contains("Content-Transfer-Encoding: quoted-printable")
|
||||
.assert_contains("ℌ𝔢𝔩𝔭 𝔪𝔢 𝔢𝔵𝔭𝔬𝔯𝔱 𝔪𝔶 𝔟𝔬𝔬𝔨")
|
||||
.assert_contains("Vandelay");
|
||||
let fraktur_utf16_le: Vec<u8> = "ℌ𝔢𝔩𝔭 𝔪𝔢 𝔢𝔵𝔭𝔬𝔯𝔱 𝔪𝔶 𝔟𝔬𝔬𝔨"
|
||||
.encode_utf16()
|
||||
.flat_map(|c| c.to_le_bytes())
|
||||
.collect();
|
||||
imap.assert_last_contains_bytes(&fraktur_utf16_le);
|
||||
|
||||
// We are in EXAMINE mode, fetching body should not set \Seen
|
||||
imap.send("UID FETCH 10 (FLAGS)").await;
|
||||
@@ -99,7 +103,7 @@ pub async fn test(imap: &mut ImapConnection, _imap_check: &mut ImapConnection) {
|
||||
.await;
|
||||
imap.assert_read(Type::Tagged, ResponseType::Ok)
|
||||
.await
|
||||
.assert_contains("BINARY[1] {175}")
|
||||
.assert_contains("BINARY[1] ~{175}")
|
||||
.assert_contains("BINARY.SIZE[1] 175")
|
||||
.assert_contains("BODY[1.TEXT] {239}");
|
||||
|
||||
|
||||
@@ -61,6 +61,17 @@ pub async fn test(imap: &mut ImapConnection, imap_check: &mut ImapConnection, te
|
||||
.await
|
||||
.assert_equals("* SEARCH 10");
|
||||
|
||||
imap_check
|
||||
.send(concat!(
|
||||
"UID SEARCH CHARSET UTF-8 TEXT {75+}\r\n",
|
||||
"ℌ𝔢𝔩𝔭 𝔪𝔢 𝔢𝔵𝔭𝔬𝔯𝔱 𝔪𝔶 𝔟𝔬𝔬𝔨"
|
||||
))
|
||||
.await;
|
||||
imap_check
|
||||
.assert_read(Type::Tagged, ResponseType::Ok)
|
||||
.await
|
||||
.assert_equals("* SEARCH 10");
|
||||
|
||||
imap_check
|
||||
.send("UID SEARCH NOT (FROM nathaniel ANSWERED)")
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user