Descriptions from exif data with only whitespeces are considered empty
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
I noticed that pictures taken with Ubuntu-Touch have whitespace in one of the fields This should just be ignored imo
This commit is contained in:
parent
f50cffd134
commit
66a04cead3
3 changed files with 21 additions and 0 deletions
|
@ -35,6 +35,8 @@ defp read_when_empty(_, file, tag) do
|
||||||
{tag_content, 0} =
|
{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: true, parallelism: true)
|
||||||
|
|
||||||
|
tag_content = String.trim(tag_content)
|
||||||
|
|
||||||
if tag_content != "" and
|
if tag_content != "" and
|
||||||
String.length(tag_content) <=
|
String.length(tag_content) <=
|
||||||
Pleroma.Config.get([:instance, :description_limit]),
|
Pleroma.Config.get([:instance, :description_limit]),
|
||||||
|
|
BIN
test/fixtures/image_with_imagedescription_and_caption-abstract_whitespaces.jpg
vendored
Normal file
BIN
test/fixtures/image_with_imagedescription_and_caption-abstract_whitespaces.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 785 B |
|
@ -83,6 +83,25 @@ test "Return nil when image description from EXIF data exceeds the maximum lengt
|
||||||
{:ok, :filtered, @uploads}
|
{:ok, :filtered, @uploads}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "Ignores content with only whitespace" do
|
||||||
|
uploads = %Pleroma.Upload{
|
||||||
|
name: "non-existant.jpg",
|
||||||
|
content_type: "image/jpeg",
|
||||||
|
path:
|
||||||
|
Path.absname(
|
||||||
|
"test/fixtures/image_with_imagedescription_and_caption-abstract_whitespaces.jpg"
|
||||||
|
),
|
||||||
|
tempfile:
|
||||||
|
Path.absname(
|
||||||
|
"test/fixtures/image_with_imagedescription_and_caption-abstract_whitespaces.jpg"
|
||||||
|
),
|
||||||
|
description: nil
|
||||||
|
}
|
||||||
|
|
||||||
|
assert Filter.Exiftool.ReadDescription.filter(uploads) ==
|
||||||
|
{:ok, :filtered, uploads}
|
||||||
|
end
|
||||||
|
|
||||||
test "Return nil when image description from EXIF data can't be read" do
|
test "Return nil when image description from EXIF data can't be read" do
|
||||||
uploads = %Pleroma.Upload{
|
uploads = %Pleroma.Upload{
|
||||||
name: "non-existant.jpg",
|
name: "non-existant.jpg",
|
||||||
|
|
Loading…
Reference in a new issue