Commit d02f1120 authored by rinpatch's avatar rinpatch
Browse files

Content-Disposition regex improvements

parent 958227d5
Pipeline #9002 passed with stages
in 4 minutes and 23 seconds
...@@ -316,9 +316,9 @@ defp build_resp_content_disposition_header(headers, opts) do ...@@ -316,9 +316,9 @@ defp build_resp_content_disposition_header(headers, opts) do
{{"content-disposition", content_disposition_string}, _} = {{"content-disposition", content_disposition_string}, _} =
List.keytake(headers, "content-disposition", 0) List.keytake(headers, "content-disposition", 0)
[name] = [name | _] =
Regex.run( Regex.run(
~r/filename=\"(.*)\"/u, ~r/filename="((?:[^"\\]|\\.)*)"/u,
content_disposition_string || "", content_disposition_string || "",
capture: :all_but_first capture: :all_but_first
) )
...@@ -328,7 +328,7 @@ defp build_resp_content_disposition_header(headers, opts) do ...@@ -328,7 +328,7 @@ defp build_resp_content_disposition_header(headers, opts) do
MatchError -> Keyword.get(opts, :attachment_name, "attachment") MatchError -> Keyword.get(opts, :attachment_name, "attachment")
end end
disposition = "attachment; filename=" <> name disposition = "attachment; filename=\"#{name}\""
List.keystore(headers, "content-disposition", 0, {"content-disposition", disposition}) List.keystore(headers, "content-disposition", 0, {"content-disposition", disposition})
else else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment