fix: Treat and send images that can't be decoded as Viewtype::File

Otherwise unsupported and corrupted images are displayed in the "Images" tab in UIs and that looks
as a Delta Chat bug. This should be a rare case though, so log it as error and let the user know
that metadata isn't removed from the image at least.
This commit is contained in:
iequidoo
2025-06-06 16:24:54 -03:00
committed by iequidoo
parent cba9eb98d6
commit acba27a328
5 changed files with 84 additions and 48 deletions

View File

@@ -3723,6 +3723,28 @@ async fn test_jpeg_with_png_ext() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_nonimage_with_png_ext() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = &tcm.alice().await;
let bob = &tcm.bob().await;
let alice_chat = alice.create_chat(bob).await;
let bytes = include_bytes!("../../test-data/message/thunderbird_with_autocrypt.eml");
let file = alice.get_blobdir().join("screenshot.png");
tokio::fs::write(&file, bytes).await?;
let mut msg = Message::new(Viewtype::Image);
msg.set_file_and_deduplicate(alice, &file, Some("screenshot.png"), None)?;
let sent_msg = alice.send_msg(alice_chat.get_id(), &mut msg).await;
assert_eq!(msg.viewtype, Viewtype::File);
assert_eq!(msg.get_filemime().unwrap(), "application/octet-stream");
let msg_bob = bob.recv_msg(&sent_msg).await;
assert_eq!(msg_bob.viewtype, Viewtype::File);
assert_eq!(msg_bob.get_filemime().unwrap(), "application/octet-stream");
Ok(())
}
/// Tests that info message is ignored when constructing `In-Reply-To`.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_info_not_referenced() -> Result<()> {