diff options
author | Stan Hu <stanhu@gmail.com> | 2018-11-26 14:07:55 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-11-26 14:14:48 -0800 |
commit | e8da70e66ca15e91ba9a1ffd553f7657eb2e90ff (patch) | |
tree | 2a973ea20861ea3a48c914a1647feb334bbadbd2 /spec/helpers | |
parent | deaf3af7e5f357f3e8d91f7f2d49ad3ce001ba68 (diff) | |
download | gitlab-ce-e8da70e66ca15e91ba9a1ffd553f7657eb2e90ff.tar.gz |
Fix handling of filenames with hash characters in tree view
Addressable::URI interprets the `#` in a URI as a URI fragment
and does not escape it, but Rails has special helpers that treats
these as bona-fide characters that need to be escaped.
Closes https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23368
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/tree_helper_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb index ab4566e261b..4a62e696cd9 100644 --- a/spec/helpers/tree_helper_spec.rb +++ b/spec/helpers/tree_helper_spec.rb @@ -5,6 +5,16 @@ describe TreeHelper do let(:repository) { project.repository } let(:sha) { 'c1c67abbaf91f624347bb3ae96eabe3a1b742478' } + def create_file(filename) + project.repository.create_file( + project.creator, + filename, + 'test this', + message: "Automatically created file #{filename}", + branch_name: 'master' + ) + end + describe '.render_tree' do before do @id = sha @@ -57,6 +67,15 @@ describe TreeHelper do expect(fast_path).to start_with('/gitlab/root') end + + it 'encodes files starting with #' do + filename = '#test-file' + create_file(filename) + + fast_path = fast_project_blob_path(project, filename) + + expect(fast_path).to end_with('%23test-file') + end end describe '.fast_project_tree_path' do @@ -73,6 +92,15 @@ describe TreeHelper do expect(fast_path).to start_with('/gitlab/root') end + + it 'encodes files starting with #' do + filename = '#test-file' + create_file(filename) + + fast_path = fast_project_tree_path(project, filename) + + expect(fast_path).to end_with('%23test-file') + end end describe 'flatten_tree' do |