From 024bb27fc70b7352610a6d1b73a7af2f09465edd Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 11 Feb 2023 00:30:52 -0500 Subject: Ignores in exiftool read descriptions --- ...n_and_caption-abstract_and_stray_data_after.png | Bin 0 -> 820 bytes test/fixtures/image_with_stray_data_after.png | Bin 0 -> 104435 bytes .../filter/exiftool/read_description_test.exs | 27 +++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png create mode 100755 test/fixtures/image_with_stray_data_after.png (limited to 'test') diff --git a/test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png b/test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png new file mode 100644 index 000000000..7ce8640fa Binary files /dev/null and b/test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png differ diff --git a/test/fixtures/image_with_stray_data_after.png b/test/fixtures/image_with_stray_data_after.png new file mode 100755 index 000000000..a280e4377 Binary files /dev/null and b/test/fixtures/image_with_stray_data_after.png differ diff --git a/test/pleroma/upload/filter/exiftool/read_description_test.exs b/test/pleroma/upload/filter/exiftool/read_description_test.exs index 7389fda47..7cc83969d 100644 --- a/test/pleroma/upload/filter/exiftool/read_description_test.exs +++ b/test/pleroma/upload/filter/exiftool/read_description_test.exs @@ -42,6 +42,33 @@ defmodule Pleroma.Upload.Filter.Exiftool.ReadDescriptionTest do {:ok, :filtered, uploads_after} end + test "Ignores warnings" do + uploads = %Pleroma.Upload{ + name: "image_with_imagedescription_and_caption-abstract_and_stray_data_after.png", + content_type: "image/png", + path: + Path.absname( + "test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png" + ), + tempfile: + Path.absname( + "test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png" + ) + } + + assert {:ok, :filtered, %{description: "a descriptive white pixel"}} = + Filter.Exiftool.ReadDescription.filter(uploads) + + uploads = %Pleroma.Upload{ + name: "image_with_stray_data_after.png", + content_type: "image/png", + path: Path.absname("test/fixtures/image_with_stray_data_after.png"), + tempfile: Path.absname("test/fixtures/image_with_stray_data_after.png") + } + + assert {:ok, :filtered, %{description: nil}} = Filter.Exiftool.ReadDescription.filter(uploads) + end + test "otherwise returns iptc:Caption-Abstract when present" do upload = %Pleroma.Upload{ name: "image_with_caption-abstract.jpg", -- cgit v1.2.3