From cb21bf5fc225899ad6cf87f5ab0253506cf0531e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Mah=C3=A9?= Date: Tue, 26 Jun 2018 13:45:47 -0700 Subject: [PATCH] filter exif data #187 --- config/config.exs | 4 +++- lib/pleroma/upload.ex | 8 ++++++++ mix.exs | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/config.exs b/config/config.exs index cf6cbaa9d..fd9662aea 100644 --- a/config/config.exs +++ b/config/config.exs @@ -10,7 +10,9 @@ config :pleroma, ecto_repos: [Pleroma.Repo] config :pleroma, Pleroma.Repo, types: Pleroma.PostgresTypes -config :pleroma, Pleroma.Upload, uploads: "uploads" +config :pleroma, Pleroma.Upload, + uploads: "uploads", + strip_exif: false # Configures the endpoint config :pleroma, Pleroma.Web.Endpoint, diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 43df0d418..dee281f5b 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -80,6 +80,14 @@ defmodule Pleroma.Upload do } end + def strip_exif_data(file) do + settings = Application.get_env(:pleroma, Pleroma.Upload) + @do_strip = Keyword.fetch!(settings, :strip_exif) + if @do_strip == true do + Mogrify.open(file) |> Mogrify.custom("strip") |> Mogrify.save(in_place: true) + end + end + def upload_path do settings = Application.get_env(:pleroma, Pleroma.Upload) Keyword.fetch!(settings, :uploads) diff --git a/mix.exs b/mix.exs index 281687294..cc279a7f9 100644 --- a/mix.exs +++ b/mix.exs @@ -47,7 +47,8 @@ defmodule Pleroma.Mixfile do {:jason, "~> 1.0"}, {:ex_machina, "~> 2.0", only: :test}, {:credo, "~> 0.7", only: [:dev, :test]}, - {:mock, "~> 0.3.0", only: :test} + {:mock, "~> 0.3.0", only: :test}, + {:mogrify, "~> 0.6.1"} ] end