diff options
| author | rinpatch <rinpatch@sdf.org> | 2019-03-15 01:36:29 +0300 | 
|---|---|---|
| committer | rinpatch <rinpatch@sdf.org> | 2019-03-15 01:36:29 +0300 | 
| commit | 958227d5563d76f4f983b7cabb6948897d93bd4b (patch) | |
| tree | 00e9fca96e59b6a37a0b0deb9c571e22144eb469 | |
| parent | 7ecc201029a8c90cf5dc3313ff78d56eb0a2445c (diff) | |
| download | pleroma-958227d5563d76f4f983b7cabb6948897d93bd4b.tar.gz pleroma-958227d5563d76f4f983b7cabb6948897d93bd4b.zip | |
MediaProxy: parse filename from content-disposition for non-whitelisted types
| -rw-r--r-- | lib/pleroma/reverse_proxy.ex | 20 | 
1 files changed, 19 insertions, 1 deletions
| diff --git a/lib/pleroma/reverse_proxy.ex b/lib/pleroma/reverse_proxy.ex index 6298b92f4..39ede8619 100644 --- a/lib/pleroma/reverse_proxy.ex +++ b/lib/pleroma/reverse_proxy.ex @@ -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 | 
