From d02f1120f9fe8e048bac6665e95e51648a50c53b Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 15 Mar 2019 08:29:51 +0300 Subject: [PATCH] Content-Disposition regex improvements --- lib/pleroma/reverse_proxy.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/reverse_proxy.ex b/lib/pleroma/reverse_proxy.ex index 39ede8619..a3f177fec 100644 --- a/lib/pleroma/reverse_proxy.ex +++ b/lib/pleroma/reverse_proxy.ex @@ -316,9 +316,9 @@ defmodule Pleroma.ReverseProxy do {{"content-disposition", content_disposition_string}, _} = List.keytake(headers, "content-disposition", 0) - [name] = + [name | _] = Regex.run( - ~r/filename=\"(.*)\"/u, + ~r/filename="((?:[^"\\]|\\.)*)"/u, content_disposition_string || "", capture: :all_but_first ) @@ -328,7 +328,7 @@ defmodule Pleroma.ReverseProxy do MatchError -> Keyword.get(opts, :attachment_name, "attachment") end - disposition = "attachment; filename=" <> name + disposition = "attachment; filename=\"#{name}\"" List.keystore(headers, "content-disposition", 0, {"content-disposition", disposition}) else -- 2.45.2