Merge branch 'bugfix/content-disposition' into 'develop'

UploadedMedia: Add missing disposition_type to Content-Disposition

Closes #3114

See merge request pleroma/pleroma!3873
This commit is contained in:
tusooa 2023-04-26 15:39:20 +00:00
commit ddf57596be
3 changed files with 5 additions and 4 deletions

1
changelog.d/3873.fix Normal file
View file

@ -0,0 +1 @@
UploadedMedia: Add missing disposition_type to Content-Disposition

View file

@ -35,9 +35,9 @@ defmodule Pleroma.Web.Plugs.UploadedMedia do
conn =
case fetch_query_params(conn) do
%{query_params: %{"name" => name}} = conn ->
name = String.replace(name, "\"", "\\\"")
name = String.replace(name, ~s["], ~s[\\"])
put_resp_header(conn, "content-disposition", "filename=\"#{name}\"")
put_resp_header(conn, "content-disposition", ~s[inline; filename="#{name}"])
conn ->
conn

View file

@ -33,11 +33,11 @@ defmodule Pleroma.Web.Plugs.UploadedMediaPlugTest do
test "sends Content-Disposition header when name param is set", %{
attachment_url: attachment_url
} do
conn = get(build_conn(), attachment_url <> "?name=\"cofe\".gif")
conn = get(build_conn(), attachment_url <> ~s[?name="cofe".gif])
assert Enum.any?(
conn.resp_headers,
&(&1 == {"content-disposition", "filename=\"\\\"cofe\\\".gif\""})
&(&1 == {"content-disposition", ~s[inline; filename="\\"cofe\\".gif"]})
)
end
end