Drop incoming vCards

Otherwise they show up as attachments in the chat.
This commit is contained in:
Alexander Krotov
2020-11-23 01:06:41 +03:00
parent 2dd90c2509
commit 241a9c5990

View File

@@ -814,6 +814,15 @@ impl MimeMessage {
return;
}
}
if mime_type.type_() == "text/x-vcard"
|| mime_type.type_() == "text/vcard"
|| filename.ends_with(".vcf")
|| filename.ends_with(".vcard")
{
return;
}
/* we have a regular file attachment,
write decoded data to new blob object */
@@ -1632,6 +1641,22 @@ mod tests {
assert_eq!(mimeparser.group_avatar, None);
}
#[async_std::test]
async fn test_mimeparser_with_vcard() {
let t = TestContext::new().await;
let raw = include_bytes!("../test-data/message/vcard.eml");
let mimeparser = MimeMessage::from_bytes(&t.ctx, &raw[..]).await.unwrap();
assert_eq!(mimeparser.parts.len(), 1);
assert_eq!(mimeparser.parts[0].typ, Viewtype::Text);
assert_eq!(
mimeparser.parts[0].msg,
"vCard example An example of vCard sent from Thunderbird."
);
assert_eq!(mimeparser.user_avatar, None);
assert_eq!(mimeparser.group_avatar, None);
}
#[async_std::test]
async fn test_mimeparser_message_kml() {
let context = TestContext::new().await;