diff options
author | tusooa <tusooa@kazv.moe> | 2023-04-26 15:39:20 +0000 |
---|---|---|
committer | tusooa <tusooa@kazv.moe> | 2023-04-26 15:39:20 +0000 |
commit | ddf57596be8f67abd8ac81fa9a9a1ca84321e7ad (patch) | |
tree | 47df23fb8b49850df45eb77d5cf91bc2b513753c | |
parent | 286b9bb66c3845ed9cf56efd05cacd3e13345671 (diff) | |
parent | 2148ef5e2fcced6a52f0cfda38abcf697698dd1a (diff) | |
download | pleroma-ddf57596be8f67abd8ac81fa9a9a1ca84321e7ad.tar.gz pleroma-ddf57596be8f67abd8ac81fa9a9a1ca84321e7ad.zip |
Merge branch 'bugfix/content-disposition' into 'develop'
UploadedMedia: Add missing disposition_type to Content-Disposition
Closes #3114
See merge request pleroma/pleroma!3873
-rw-r--r-- | changelog.d/3873.fix | 1 | ||||
-rw-r--r-- | lib/pleroma/web/plugs/uploaded_media.ex | 4 | ||||
-rw-r--r-- | test/pleroma/web/plugs/uploaded_media_plug_test.exs | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/changelog.d/3873.fix b/changelog.d/3873.fix new file mode 100644 index 000000000..4699f7b58 --- /dev/null +++ b/changelog.d/3873.fix @@ -0,0 +1 @@ +UploadedMedia: Add missing disposition_type to Content-Disposition
\ No newline at end of file diff --git a/lib/pleroma/web/plugs/uploaded_media.ex b/lib/pleroma/web/plugs/uploaded_media.ex index ad8143234..8b3bc9acb 100644 --- a/lib/pleroma/web/plugs/uploaded_media.ex +++ b/lib/pleroma/web/plugs/uploaded_media.ex @@ -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 diff --git a/test/pleroma/web/plugs/uploaded_media_plug_test.exs b/test/pleroma/web/plugs/uploaded_media_plug_test.exs index ec46b0537..8323ff6ab 100644 --- a/test/pleroma/web/plugs/uploaded_media_plug_test.exs +++ b/test/pleroma/web/plugs/uploaded_media_plug_test.exs @@ -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 |