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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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 from ea615da to 98baeb7 Compare June 6, 2025 20:29
iequidoo added 2 commits June 9, 2025 17:33
`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()`.
@iequidoo iequidoo force-pushed the iequidoo/image-as-file-if-cant-decode branch 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 added 2 commits June 9, 2025 17:58
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.
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 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
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.

1 participant