Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-11-27 01:07:55 +0300
committerStan Hu <stanhu@gmail.com>2018-11-27 01:14:48 +0300
commite8da70e66ca15e91ba9a1ffd553f7657eb2e90ff (patch)
tree2a973ea20861ea3a48c914a1647feb334bbadbd2 /spec/helpers/tree_helper_spec.rb
parentdeaf3af7e5f357f3e8d91f7f2d49ad3ce001ba68 (diff)
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/tree_helper_spec.rb')
-rw-r--r--spec/helpers/tree_helper_spec.rb28
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