MediaProxy: parse filename from content-disposition for non-whitelisted types
This commit is contained in:
parent
7ecc201029
commit
958227d556
|
@ -311,7 +311,25 @@ defp build_resp_content_disposition_header(headers, opts) do
|
||||||
end
|
end
|
||||||
|
|
||||||
if attachment? do
|
if attachment? do
|
||||||
disposition = "attachment; filename=" <> Keyword.get(opts, :attachment_name, "attachment")
|
name =
|
||||||
|
try do
|
||||||
|
{{"content-disposition", content_disposition_string}, _} =
|
||||||
|
List.keytake(headers, "content-disposition", 0)
|
||||||
|
|
||||||
|
[name] =
|
||||||
|
Regex.run(
|
||||||
|
~r/filename=\"(.*)\"/u,
|
||||||
|
content_disposition_string || "",
|
||||||
|
capture: :all_but_first
|
||||||
|
)
|
||||||
|
|
||||||
|
name
|
||||||
|
rescue
|
||||||
|
MatchError -> Keyword.get(opts, :attachment_name, "attachment")
|
||||||
|
end
|
||||||
|
|
||||||
|
disposition = "attachment; filename=" <> name
|
||||||
|
|
||||||
List.keystore(headers, "content-disposition", 0, {"content-disposition", disposition})
|
List.keystore(headers, "content-disposition", 0, {"content-disposition", disposition})
|
||||||
else
|
else
|
||||||
headers
|
headers
|
||||||
|
|
Loading…
Reference in New Issue