wf_akkoma/patches/pr814_07_fix-bmp-metadata-handling.patch

52 lines
2.2 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 495a1a71e89f3a3b67f9948f5e241a8b195f5ecf Mon Sep 17 00:00:00 2001
From: Oneric <oneric@oneric.stub>
Date: Fri, 21 Jun 2024 18:30:47 +0200
Subject: [PATCH] strip_metadata: skip BMP files
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Not _yet_ supported as of exiftool 12.87, though
at first glance it seems like standard BMP files
can't store any metadata besides colour profiles
Fixes the specific case from
https://akkoma.dev/AkkomaGang/akkoma-fe/issues/396
although the frontend shouldnt get bricked regardless.
---
lib/pleroma/upload/filter/exiftool/strip_metadata.ex | 1 +
.../upload/filter/exiftool/strip_location_test.exs | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/lib/pleroma/upload/filter/exiftool/strip_metadata.ex b/lib/pleroma/upload/filter/exiftool/strip_metadata.ex
index 912ff6a92..a2604a682 100644
--- a/lib/pleroma/upload/filter/exiftool/strip_metadata.ex
+++ b/lib/pleroma/upload/filter/exiftool/strip_metadata.ex
@@ -18,6 +18,7 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripMetadata do
# Formats not compatible with exiftool at this time
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
+ def filter(%Pleroma.Upload{content_type: "image/bmp"}), do: {:ok, :noop}
def filter(%Pleroma.Upload{content_type: "image/svg+xml"}), do: {:ok, :noop}
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
diff --git a/test/pleroma/upload/filter/exiftool/strip_location_test.exs b/test/pleroma/upload/filter/exiftool/strip_location_test.exs
index 2e017cd7e..1f798556b 100644
--- a/test/pleroma/upload/filter/exiftool/strip_location_test.exs
+++ b/test/pleroma/upload/filter/exiftool/strip_location_test.exs
@@ -115,6 +115,15 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripMetadataTest do
assert Filter.Exiftool.StripMetadata.filter(upload) == {:ok, :noop}
end
+ test "verify bmp files are skipped" do
+ upload = %Pleroma.Upload{
+ name: "sample.bmp",
+ content_type: "image/bmp"
+ }
+
+ assert Filter.Exiftool.StripMetadata.filter(upload) == {:ok, :noop}
+ end
+
test "verify svg files are skipped" do
upload = %Pleroma.Upload{
name: "sample.svg",