From e8fca8882aa4d8c9fc5e9f27f625beca19205380 Mon Sep 17 00:00:00 2001 From: Dmytro Poltavchenko Date: Thu, 5 Jan 2023 14:14:46 +0000 Subject: Added SVG to formats not compatible with exiftool --- lib/pleroma/upload/filter/exiftool/strip_location.ex | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/pleroma/upload/filter/exiftool/strip_location.ex b/lib/pleroma/upload/filter/exiftool/strip_location.ex index 6100527d3..0388b3aba 100644 --- a/lib/pleroma/upload/filter/exiftool/strip_location.ex +++ b/lib/pleroma/upload/filter/exiftool/strip_location.ex @@ -14,6 +14,7 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocation do # 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+xml"}), do: {:ok, :noop} def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do try do -- cgit v1.2.3 From d5125e6ce75ee9c2cf54e5399625d7a94e313571 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 5 Jan 2023 11:29:06 -0500 Subject: B StripLocation: Add test, work for all svgs. --- lib/pleroma/upload/filter/exiftool/strip_location.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/upload/filter/exiftool/strip_location.ex b/lib/pleroma/upload/filter/exiftool/strip_location.ex index 0388b3aba..f2bcc4622 100644 --- a/lib/pleroma/upload/filter/exiftool/strip_location.ex +++ b/lib/pleroma/upload/filter/exiftool/strip_location.ex @@ -14,7 +14,7 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocation do # 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+xml"}), 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 -- cgit v1.2.3 From 3ab34048172f9fd99ad106d71b4e7ae5c57ab9e1 Mon Sep 17 00:00:00 2001 From: tusooa Date: Wed, 18 Jan 2023 18:36:52 -0500 Subject: Fix block_from_stranger setting --- lib/pleroma/notification.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index aba6096bc..60c1a80ba 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -679,7 +679,7 @@ defmodule Pleroma.Notification do cond do opts[:type] == "poll" -> false user.ap_id == actor -> false - !User.following?(follower, user) -> true + !User.following?(user, follower) -> true true -> false end end -- cgit v1.2.3 From 88ce0e8b24582020276dfc292abbf000211f9479 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 29 Dec 2022 19:42:14 +0000 Subject: Fix rel="me" Cachex for this was not started --- lib/pleroma/application.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 1c1db8c10..e68a3c57e 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -209,7 +209,8 @@ defmodule Pleroma.Application do build_cachex("chat_message_id_idempotency_key", expiration: chat_message_id_idempotency_key_expiration(), limit: 500_000 - ) + ), + build_cachex("rel_me", limit: 2500) ] end -- cgit v1.2.3 From 1b82fd95d414a411f4aaae125c66c8df53f84f21 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 30 Dec 2022 15:36:21 -0500 Subject: Remove unwanted code specific to MIX_ENV=test --- lib/pleroma/web/rel_me.ex | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/rel_me.ex b/lib/pleroma/web/rel_me.ex index 98fbc1c59..ceb6a05f0 100644 --- a/lib/pleroma/web/rel_me.ex +++ b/lib/pleroma/web/rel_me.ex @@ -9,17 +9,13 @@ defmodule Pleroma.Web.RelMe do recv_timeout: 2_000 ] - if Pleroma.Config.get(:env) == :test do - def parse(url) when is_binary(url), do: parse_url(url) - else - @cachex Pleroma.Config.get([:cachex, :provider], Cachex) - def parse(url) when is_binary(url) do - @cachex.fetch!(:rel_me_cache, url, fn _ -> - {:commit, parse_url(url)} - end) - rescue - e -> {:error, "Cachex error: #{inspect(e)}"} - end + @cachex Pleroma.Config.get([:cachex, :provider], Cachex) + def parse(url) when is_binary(url) do + @cachex.fetch!(:rel_me_cache, url, fn _ -> + {:commit, parse_url(url)} + end) + rescue + e -> {:error, "Cachex error: #{inspect(e)}"} end def parse(_), do: {:error, "No URL provided"} -- cgit v1.2.3 From 1c225bfd6e86b58d2a70eb74d3774a438dc7796b Mon Sep 17 00:00:00 2001 From: tusooa Date: Thu, 26 Jan 2023 20:17:13 -0500 Subject: Allow customizing instance languages --- lib/pleroma/web/mastodon_api/views/instance_view.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 917725839..abf7f29ab 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -27,7 +27,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do thumbnail: URI.merge(Pleroma.Web.Endpoint.url(), Keyword.get(instance, :instance_thumbnail)) |> to_string, - languages: ["en"], + languages: Keyword.get(instance, :languages, ["en"]), registrations: Keyword.get(instance, :registrations_open), approval_required: Keyword.get(instance, :account_approval_required), # Extra (not present in Mastodon): -- cgit v1.2.3 From 8e8a0f005cddf6b2cd1535ad634ac8cb8d0ca42e Mon Sep 17 00:00:00 2001 From: tusooa Date: Fri, 3 Feb 2023 15:38:08 -0500 Subject: Fix inproper content being cached in report content --- lib/pleroma/web/admin_api/report.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/admin_api/report.ex b/lib/pleroma/web/admin_api/report.ex index c79bee27e..fa89e3405 100644 --- a/lib/pleroma/web/admin_api/report.ex +++ b/lib/pleroma/web/admin_api/report.ex @@ -31,7 +31,7 @@ defmodule Pleroma.Web.AdminAPI.Report do defp make_fake_activity(act, user) do %Activity{ - id: "pleroma:fake", + id: "pleroma:fake:#{act["id"]}", data: %{ "actor" => user.ap_id, "type" => "Create", -- cgit v1.2.3 From c3a07035646b255bc5f33743d13defbaa69d9991 Mon Sep 17 00:00:00 2001 From: Alexander Tumin Date: Tue, 7 Feb 2023 15:30:07 +0300 Subject: Require related object for notifications to filter on content --- lib/pleroma/notification.ex | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 60c1a80ba..48d467c59 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -178,6 +178,7 @@ defmodule Pleroma.Notification do from([_n, a, o] in query, where: fragment("not(?->>'content' ~* ?)", o.data, ^regex) or + fragment("?->>'content' is null", o.data) or fragment("?->>'actor' = ?", o.data, ^user.ap_id) ) end -- cgit v1.2.3 From 410d50afe5e76100047563bae7a0a461790883dd Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 11 Feb 2023 00:30:52 -0500 Subject: Ignores in exiftool read descriptions --- lib/pleroma/upload/filter/exiftool/read_description.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') 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) -- cgit v1.2.3 From e4925f813afda5883fd12a48b99b2b12f83678d9 Mon Sep 17 00:00:00 2001 From: tusooa Date: Thu, 29 Dec 2022 14:33:46 -0500 Subject: Sanitize filenames when uploading --- lib/pleroma/web/activity_pub/activity_pub.ex | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index b9206b4da..1ab2db94a 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1453,13 +1453,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do @spec upload(Upload.source(), keyword()) :: {:ok, Object.t()} | {:error, any()} def upload(file, opts \\ []) do - with {:ok, data} <- Upload.store(file, opts) do + with {:ok, data} <- Upload.store(sanitize_upload_file(file), opts) do obj_data = Maps.put_if_present(data, "actor", opts[:actor]) Repo.insert(%Object{data: obj_data}) end end + defp sanitize_upload_file(%Plug.Upload{filename: filename} = upload) when is_binary(filename) do + %Plug.Upload{ + upload + | filename: Path.basename(filename) + } + end + + defp sanitize_upload_file(upload), do: upload + @spec get_actor_url(any()) :: binary() | nil defp get_actor_url(url) when is_binary(url), do: url defp get_actor_url(%{"href" => href}) when is_binary(href), do: href -- cgit v1.2.3