Page MenuHomePhorge

No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None
diff --git a/.gitignore b/.gitignore
index b0bb9b2e5..c0d017951 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,65 +1,65 @@
# App artifacts
/_build
/db
/deps
/*.ez
/test/instance
/test/uploads
/.elixir_ls
-/test/fixtures/DSCN0010_tmp.jpg
+/test/fixtures/DSCN0010_tmp*
/test/fixtures/test_tmp.txt
/test/fixtures/image_tmp.jpg
/test/tmp/
/doc
/instance
/priv/ssh_keys
# Prevent committing custom emojis
/priv/static/emoji/custom/*
# Generated on crash by the VM
erl_crash.dump
# Files matching config/*.secret.exs pattern contain sensitive
# data and you should not commit them into version control.
#
# Alternatively, you may comment the line below and commit the
# secrets files as long as you replace their contents by environment
# variables.
/config/*.secret.exs
/config/generated_config.exs
/config/runtime.exs
/config/*.env
# Database setup file, some may forget to delete it
/config/setup_db*.psql
.DS_Store
.env
# Editor config
/.vscode/
# Prevent committing docs files
/priv/static/doc/*
docs/generated_config.md
# Code test coverage
/cover
/Elixir.*.coverdata
/coverage.xml
.idea
pleroma.iml
# asdf
.tool-versions
# Editor temp files
*~
*#
*.swp
archive-*
.gitlab-ci-local
diff --git a/changelog.d/4167-strip-gps-info-in-png.fix b/changelog.d/4167-strip-gps-info-in-png.fix
new file mode 100644
index 000000000..e8d5c2908
--- /dev/null
+++ b/changelog.d/4167-strip-gps-info-in-png.fix
@@ -0,0 +1 @@
+Ensure that StripLocation actually removes everything resembling GPS data from PNGs
diff --git a/lib/pleroma/upload/filter/exiftool/strip_location.ex b/lib/pleroma/upload/filter/exiftool/strip_location.ex
index 8becee712..1744a286d 100644
--- a/lib/pleroma/upload/filter/exiftool/strip_location.ex
+++ b/lib/pleroma/upload/filter/exiftool/strip_location.ex
@@ -1,30 +1,32 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Upload.Filter.Exiftool.StripLocation do
@moduledoc """
Strips GPS related EXIF tags and overwrites the file in place.
Also strips or replaces filesystem metadata e.g., timestamps.
"""
@behaviour Pleroma.Upload.Filter
# Formats not compatible with exiftool at this time
def filter(%Pleroma.Upload{content_type: "image/heic"}), do: {:ok, :noop}
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
def filter(%Pleroma.Upload{content_type: "image/svg" <> _}), do: {:ok, :noop}
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
try do
- case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true) do
+ case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", "-png:all=", file],
+ parallelism: true
+ ) do
{_response, 0} -> {:ok, :filtered}
{error, 1} -> {:error, error}
end
rescue
e in ErlangError ->
{:error, "#{__MODULE__}: #{inspect(e)}"}
end
end
def filter(_), do: {:ok, :noop}
end
diff --git a/test/fixtures/DSCN0010.png b/test/fixtures/DSCN0010.png
new file mode 100644
index 000000000..66f2f05f7
Binary files /dev/null and b/test/fixtures/DSCN0010.png differ
diff --git a/test/pleroma/upload/filter/exiftool/strip_location_test.exs b/test/pleroma/upload/filter/exiftool/strip_location_test.exs
index bcb5f3f60..4dcd4dce3 100644
--- a/test/pleroma/upload/filter/exiftool/strip_location_test.exs
+++ b/test/pleroma/upload/filter/exiftool/strip_location_test.exs
@@ -1,49 +1,51 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Upload.Filter.Exiftool.StripLocationTest do
use Pleroma.DataCase, async: true
alias Pleroma.Upload.Filter
test "apply exiftool filter" do
assert Pleroma.Utils.command_available?("exiftool")
- File.cp!(
- "test/fixtures/DSCN0010.jpg",
- "test/fixtures/DSCN0010_tmp.jpg"
- )
-
- upload = %Pleroma.Upload{
- name: "image_with_GPS_data.jpg",
- content_type: "image/jpeg",
- path: Path.absname("test/fixtures/DSCN0010.jpg"),
- tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
- }
-
- assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
-
- {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.jpg"])
- {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.jpg"])
-
- refute exif_original == exif_filtered
- assert String.match?(exif_original, ~r/GPS/)
- refute String.match?(exif_filtered, ~r/GPS/)
+ ~w{jpg png}
+ |> Enum.map(fn type ->
+ File.cp!(
+ "test/fixtures/DSCN0010.#{type}",
+ "test/fixtures/DSCN0010_tmp.#{type}"
+ )
+
+ upload = %Pleroma.Upload{
+ name: "image_with_GPS_data.#{type}",
+ content_type: "image/jpeg",
+ path: Path.absname("test/fixtures/DSCN0010.#{type}"),
+ tempfile: Path.absname("test/fixtures/DSCN0010_tmp.#{type}")
+ }
+
+ assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
+
+ {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.#{type}"])
+ {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.#{type}"])
+
+ assert String.match?(exif_original, ~r/GPS/)
+ refute String.match?(exif_filtered, ~r/GPS/)
+ end)
end
- test "verify webp, heic, svg files are skipped" do
+ test "verify webp, heic, svg files are skipped" do
uploads =
~w{webp heic svg svg+xml}
|> Enum.map(fn type ->
%Pleroma.Upload{
name: "sample.#{type}",
content_type: "image/#{type}"
}
end)
uploads
|> Enum.each(fn upload ->
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :noop}
end)
end
end

File Metadata

Mime Type
text/x-diff
Expires
Sat, Aug 8, 6:53 PM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1723823
Default Alt Text
(5 KB)

Event Timeline