diff options
author | winniehell <git@winniehell.de> | 2016-08-18 23:48:25 +0300 |
---|---|---|
committer | winniehell <git@winniehell.de> | 2016-08-19 19:08:08 +0300 |
commit | bb48a0faea00473c24e77e9e7464392f9de2c4fb (patch) | |
tree | 6ce34f1c8c3506c2c9a5389fcb188094f54d6c00 | |
parent | f3ee7fc80b10f58d0dbd4ea683e65d5d6ac01666 (diff) |
Do not escape URI when extracting path (!5878)
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/extracts_path.rb | 12 | ||||
-rw-r--r-- | spec/lib/extracts_path_spec.rb | 11 |
3 files changed, 4 insertions, 20 deletions
diff --git a/CHANGELOG b/CHANGELOG index ec6246a0681..61047145f1a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ v 8.11.0 (unreleased) - Fix CI status icon link underline (ClemMakesApps) - The Repository class is now instrumented - Fix commit mention font inconsistency (ClemMakesApps) + - Do not escape URI when extracting path !5878 (winniehell) - Fix filter label tooltip HTML rendering (ClemMakesApps) - Cache the commit author in RequestStore to avoid extra lookups in PostReceive - Expand commit message width in repo view (ClemMakesApps) diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 84688f6646e..a293fa2752f 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -94,7 +94,9 @@ module ExtractsPath @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } @options = HashWithIndifferentAccess.new(@options) - @id = Addressable::URI.normalize_component(get_id) + @id = params[:id] || params[:ref] + @id += "/" + params[:path] unless params[:path].blank? + @ref, @path = extract_ref(@id) @repo = @project.repository if @options[:extended_sha1].blank? @@ -116,12 +118,4 @@ module ExtractsPath def tree @tree ||= @repo.tree(@commit.id, @path) end - - private - - def get_id - id = params[:id] || params[:ref] - id += "/" + params[:path] unless params[:path].blank? - id - end end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 1d08daee059..86d04ecfa36 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -30,17 +30,6 @@ describe ExtractsPath, lib: true do expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb") end - context 'escaped slash character in ref' do - let(:ref) { 'improve%2Fawesome' } - - it 'has no escape sequences in @ref or @logs_path' do - assign_ref_vars - - expect(@ref).to eq('improve/awesome') - expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb") - end - end - context 'ref contains %20' do let(:ref) { 'foo%20bar' } |