diff options
author | Sean McGivern <sean@gitlab.com> | 2018-12-31 16:42:54 +0300 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-01-02 20:37:29 +0300 |
commit | 3060be7a7339176ae780f8f2654820b616ebc6a6 (patch) | |
tree | 16d8bcb392dfc6cdb7fc5a97e9f94cf734240436 /lib | |
parent | 96b39ebcb02ea4ebd858c02ecb792b093471935e (diff) |
Merge branch 'fj-55781-fix-api-blob-content-disposition' into 'master'
Fixed content-disposition in blob and files API endpoint
Closes #55781
See merge request gitlab-org/gitlab-ce!24078
(cherry picked from commit ca14b70d5201852751d79d6a0827b81689fff5be)
2cd47bba Fixed api content-disposition in blob and files endpoint
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 2cceb2ec798..8187886b6d7 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -494,7 +494,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 @@ -527,5 +527,11 @@ module API params[:archived] end + + def content_disposition(disposition, filename) + disposition += %(; filename=#{filename.inspect}) if filename.present? + + disposition + end end end |