Quellcode durchsuchen

MediaProxy: parse filename from content-disposition for non-whitelisted types

tags/v1.1.4
rinpatch vor 5 Jahren
Ursprung
Commit
958227d556
1 geänderte Dateien mit 19 neuen und 1 gelöschten Zeilen
  1. +19
    -1
      lib/pleroma/reverse_proxy.ex

+ 19
- 1
lib/pleroma/reverse_proxy.ex Datei anzeigen

@@ -311,7 +311,25 @@ defmodule Pleroma.ReverseProxy do
end

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})
else
headers


Laden…
Abbrechen
Speichern