diff --git a/config/config.exs b/config/config.exs index ff0936460..50672cfc8 100644 --- a/config/config.exs +++ b/config/config.exs @@ -66,7 +66,7 @@ config :pleroma, Pleroma.Upload, filename_display_max_length: 30, default_description: nil, base_url: nil, - allowed_mime_types: ["image", "audio", "video", "text"] + allowed_mime_types: ["image", "audio", "video"] config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads" diff --git a/lib/pleroma/web/plugs/instance_static.ex b/lib/pleroma/web/plugs/instance_static.ex index 0f50b1a09..f82b9a098 100644 --- a/lib/pleroma/web/plugs/instance_static.ex +++ b/lib/pleroma/web/plugs/instance_static.ex @@ -51,25 +51,25 @@ defmodule Pleroma.Web.Plugs.InstanceStatic do |> Map.put(:from, from) |> Map.put(:content_types, false) - # Get sanitized content type before calling Plug.Static - # Include "text" to allow HTML files and other text-based content - allowed_mime_types = - Pleroma.Config.get([Pleroma.Upload, :allowed_mime_types], [ - "image", - "audio", - "video", - "text" - ]) - - conn = set_content_type(conn, %{allowed_mime_types: allowed_mime_types}, conn.request_path) + conn = set_content_type(conn, conn.request_path) # Call Plug.Static with our sanitized content-type Plug.Static.call(conn, opts) end - defp set_content_type(conn, opts, filepath) do + defp set_content_type(conn, "/emoji/" <> filepath) do real_mime = MIME.from_path(filepath) - clean_mime = Pleroma.Web.Plugs.Utils.get_safe_mime_type(opts, real_mime) + + clean_mime = + Pleroma.Web.Plugs.Utils.get_safe_mime_type(%{allowed_mime_types: ["image"]}, real_mime) + put_resp_header(conn, "content-type", clean_mime) end + + defp set_content_type(conn, filepath) do + real_mime = MIME.from_path(filepath) + put_resp_header(conn, "content-type", real_mime) + end end + +# I think this needs to be uncleaned except for emoji. diff --git a/test/pleroma/web/plugs/instance_static_test.exs b/test/pleroma/web/plugs/instance_static_test.exs index ee0dd4acb..e8cf17f3f 100644 --- a/test/pleroma/web/plugs/instance_static_test.exs +++ b/test/pleroma/web/plugs/instance_static_test.exs @@ -63,15 +63,47 @@ defmodule Pleroma.Web.Plugs.InstanceStaticTest do assert html_response(index, 200) == "