fix: prepare_msg_blob(): If cannot recode image, don't use it if it has Exif

We mustn't send images with Exif as it can leak metadata such as location, camera model, etc.
This commit is contained in:
iequidoo
2023-08-14 17:51:05 -03:00
committed by iequidoo
parent ee28298d7f
commit 3e07f2c173
2 changed files with 22 additions and 10 deletions

View File

@@ -2035,13 +2035,8 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> {
let mut maybe_sticker = msg.viewtype == Viewtype::Sticker;
if msg.viewtype == Viewtype::Image || maybe_sticker {
// TODO: Ignore errors only if the image has no Exif.
if let Err(err) = blob.recode_to_image_size(context, &mut maybe_sticker).await {
warn!(
context,
"Cannot recode image, using original data: {err:#}."
);
}
blob.recode_to_image_size(context, &mut maybe_sticker)
.await?;
if !maybe_sticker {
msg.viewtype = Viewtype::Image;
}