From 2cd47bba9a4ee1b503b37c548826ef527c4e49ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Mon, 31 Dec 2018 10:13:09 +0100 Subject: Fixed api content-disposition in blob and files endpoint --- lib/api/helpers.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index c3eca713712..6c1a730935a 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -496,7 +496,7 @@ module API def send_git_blob(repository, blob) env['api.format'] = :txt content_type 'text/plain' - header['Content-Disposition'] = "attachment; filename=#{blob.name.inspect}" + header['Content-Disposition'] = content_disposition('attachment', blob.name) header(*Gitlab::Workhorse.send_git_blob(repository, blob)) end @@ -529,5 +529,11 @@ module API params[:archived] end + + def content_disposition(disposition, filename) + disposition += %(; filename=#{filename.inspect}) if filename.present? + + disposition + end end end -- cgit v1.2.1