+
Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 8, 2025

Conversation

iequidoo
Copy link
Collaborator

@iequidoo iequidoo commented Jun 6, 2025

See commit messages and also deltachat/deltachat-desktop#3879 for reasoning.

@iequidoo iequidoo marked this pull request as draft June 6, 2025 19:37
@iequidoo iequidoo force-pushed the iequidoo/image-as-file-if-cant-decode branch from 7d529fe to ea615da Compare June 6, 2025 20:07
@iequidoo iequidoo marked this pull request as ready for review June 6, 2025 20:14
@iequidoo iequidoo requested review from Simon-Laux and link2xt June 6, 2025 20:15
@iequidoo iequidoo force-pushed the iequidoo/image-as-file-if-cant-decode branch 2 times, most recently from 98baeb7 to 5ba3d29 Compare June 9, 2025 20:34
@iequidoo
Copy link
Collaborator Author

iequidoo commented Jun 9, 2025

Tested in Desktop. Note that if an image is sent as File, it will be shown as Image and have "image/..." mimetype on both sides, i.e. the behavior doesn't change, because we don't try to decode the image and don't know that it has the wrong format. EDIT: This is fixed by feat: Check images passed as File before making them Image.

@iequidoo iequidoo force-pushed the iequidoo/image-as-file-if-cant-decode branch from 5ba3d29 to 4917336 Compare June 9, 2025 22:53
@iequidoo
Copy link
Collaborator Author

iequidoo commented Jun 9, 2025

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

Now i think this isn't a correct behavior. If smth can't be sent as image, the metadata isn't removed and a potentially big file is sent. It's better to fail sending. The user should retry to send the "image" as File. Going to fix this.

EDIT: I have no idea why we implemented this unsafe sending of the original file. Does anyone know?
EDIT: Ok, this is a separate problem and should be fixed in another PR.

@iequidoo iequidoo marked this pull request as draft June 9, 2025 23:15
@iequidoo iequidoo marked this pull request as ready for review June 10, 2025 10:04
@iequidoo iequidoo requested a review from Hocuri June 12, 2025 20:20
@iequidoo iequidoo force-pushed the iequidoo/image-as-file-if-cant-decode branch from 4917336 to 4d2939f Compare June 25, 2025 01:19
@iequidoo iequidoo force-pushed the iequidoo/image-as-file-if-cant-decode branch from 4d2939f to beb52a1 Compare June 28, 2025 22:29
@@ -500,10 +497,11 @@ impl<'a> BlobObject<'a> {
Ok(_) => res,
Err(err) => {
if !is_avatar && no_exif {
warn!(
error!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error! messages are displayed as a toast in the UI, do we really want it here? Not being able to decode an image is not an exceptional state, users may drop HEIF images into the UI and we cannot prevent this.

Copy link
Collaborator Author

@iequidoo iequidoo Jul 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, this error is not translated, but i wanted to warn the user that the original data will be sent which may contain sensitive metadata, and the message may be huge.

EDIT: no_exif is false by default, so metadata isn't a problem. But the original file name would preserve.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed another commit, fix: Decide on filename used for sending depending on the original Viewtype, fixing this problem. Still i'd prefer this to be error! to warn the user that the message may be huge

iequidoo added 5 commits July 8, 2025 06:39
`Viewtype::Sticker` has special meaning: the file should be an image having fully transparent
pixels. But "tgs" (Telegram animated sticker) is a compressed JSON and isn't recognized by Core as
image.
Guessing mimetype is already done in `chat::prepare_msg_blob()`.
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.
…ewtype

If a user attaches an image as `File`, we should send the original filename. And vice versa, if it's
`Image` originally, we mustn't reveal the filename.

The filename used for sending is now also saved to the db, so all the sender's devices will display
the same filename in the message info.
We don't want images having unsupported format or corrupted ones to be sent as `Image` and appear in
the "Images" tab in UIs because they can't be displayed correctly.
@iequidoo iequidoo force-pushed the iequidoo/image-as-file-if-cant-decode branch from beb52a1 to 0b6154c Compare July 8, 2025 09:52
@iequidoo iequidoo requested a review from link2xt July 8, 2025 09:57
@iequidoo iequidoo merged commit 3f66ae9 into main Jul 8, 2025
28 of 29 checks passed
@iequidoo iequidoo deleted the iequidoo/image-as-file-if-cant-decode branch July 8, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载