diff options
author | tusooa <tusooa@kazv.moe> | 2023-02-11 00:30:52 -0500 |
---|---|---|
committer | tusooa <tusooa@kazv.moe> | 2023-02-11 00:30:52 -0500 |
commit | 024bb27fc70b7352610a6d1b73a7af2f09465edd (patch) | |
tree | 5cf623299f369ffeba5711ddab42a39225883d10 | |
parent | d0b781ab69971a6a950a8bcb36f5702dc999e209 (diff) | |
download | pleroma-024bb27fc70b7352610a6d1b73a7af2f09465edd.tar.gz pleroma-024bb27fc70b7352610a6d1b73a7af2f09465edd.zip |
Ignores in exiftool read descriptions
-rw-r--r-- | lib/pleroma/upload/filter/exiftool/read_description.ex | 5 | ||||
-rw-r--r-- | test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png | bin | 0 -> 820 bytes | |||
-rwxr-xr-x | test/fixtures/image_with_stray_data_after.png | bin | 0 -> 104435 bytes | |||
-rw-r--r-- | test/pleroma/upload/filter/exiftool/read_description_test.exs | 27 |
4 files changed, 31 insertions, 1 deletions
diff --git a/lib/pleroma/upload/filter/exiftool/read_description.ex b/lib/pleroma/upload/filter/exiftool/read_description.ex index 03d698a81..543b22031 100644 --- a/lib/pleroma/upload/filter/exiftool/read_description.ex +++ b/lib/pleroma/upload/filter/exiftool/read_description.ex @@ -33,7 +33,10 @@ defmodule Pleroma.Upload.Filter.Exiftool.ReadDescription do defp read_when_empty(_, file, tag) do try do {tag_content, 0} = - System.cmd("exiftool", ["-b", "-s3", tag, file], stderr_to_stdout: true, parallelism: true) + System.cmd("exiftool", ["-b", "-s3", tag, file], + stderr_to_stdout: false, + parallelism: true + ) tag_content = String.trim(tag_content) 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 Binary files differnew file mode 100644 index 000000000..7ce8640fa --- /dev/null +++ b/test/fixtures/image_with_imagedescription_and_caption-abstract_and_stray_data_after.png diff --git a/test/fixtures/image_with_stray_data_after.png b/test/fixtures/image_with_stray_data_after.png Binary files differnew file mode 100755 index 000000000..a280e4377 --- /dev/null +++ b/test/fixtures/image_with_stray_data_after.png 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", |