diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-02 12:25:28 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-02 12:25:28 +0000 |
commit | 28219ea9211d6caafa34620859ff0e879ec54c12 (patch) | |
tree | 76819d5aa057696a6cb58cfa4d36b2997836acec /spec | |
parent | 6f19e8799e4c8233b01068bf6b5406b0ba1d1105 (diff) | |
parent | 551157960e70363d35a9b24d79780c9b98c9ef3b (diff) | |
download | gitlab-ce-28219ea9211d6caafa34620859ff0e879ec54c12.tar.gz |
Merge branch 'fix-raw-controller-disposition' into 'master'
Remove the filename argument from Content-Disposition header
This MR removes the filename argument from the `Content-Disposition` header to avoid RFC 5987 and RFC 6266 encoding issues. Some browsers (e.g. Internet Explorer) do not properly decode a Unicode string properly, and this can lead to odd filenames in the raw file download. This change allows the browser to determine the filename based on the URL.
For example, if I have a file called `한글한글.pptx` and click to download it with the "Raw" button in the Files section, IE11 will ask:
![image](https://gitlab.com/stanhu/gitlab-ce/uploads/fdb688282c0d4564872deadb44c58b2c/image.png)
If you look at the `Content-Disposition` field, you see this:
![image](https://gitlab.com/stanhu/gitlab-ce/uploads/2b342b83ae1ec61fd31937163ace8ec5/image.png)
Chrome, Firefox, and Safari seem to be able to handle UTF-8 encoded filenames, even though this is not standard.
See: http://greenbytes.de/tech/tc2231/
Closes https://github.com/gitlabhq/gitlabhq/issues/9595
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/1829
I've also submitted a pull request to Rails to support RFC 6266: https://github.com/rails/rails/pull/21461
See merge request !1235
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/raw_controller_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb new file mode 100644 index 00000000000..1f921d5f05d --- /dev/null +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe Projects::RawController do + let(:public_project) { create(:project, :public) } + + describe "#show" do + context 'regular filename' do + let(:id) { 'master/README.md' } + + it 'delivers ASCII file' do + get(:show, + namespace_id: public_project.namespace.to_param, + project_id: public_project.to_param, + id: id) + + expect(response.status).to eq(200) + expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') + expect(response.header['Content-Disposition']). + to eq("inline") + end + end + end +end |