From ecbe119af13dfef707694fc7a271d60f3af8f779 Mon Sep 17 00:00:00 2001
From: Stan Hu <stanhu@gmail.com>
Date: Sun, 2 Aug 2015 00:07:23 -0700
Subject: [PATCH] Fix "Network" and "Graphs" pages for branches with encoded
 slashes

Closes #1359
---
 CHANGELOG                      |  1 +
 lib/extracts_path.rb           |  2 +-
 spec/lib/extracts_path_spec.rb | 10 ++++++++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 493d6122b99..007961b2576 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 Please view this file on the master branch, on stable branches it's out of date.
 
 v 7.14.0 (unreleased)
+  - Fix "Network" and "Graphs" pages for branches with encoded slashes (Stan Hu)
   - Fix errors deleting and creating branches with encoded slashes (Stan Hu)
   - Fix multi-line syntax highlighting (Stan Hu)
   - Fix network graph when branch name has single quotes (Stan Hu)
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index 3f420553d42..322aed5e27c 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -94,7 +94,7 @@ module ExtractsPath
     @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? }
     @options = HashWithIndifferentAccess.new(@options)
 
-    @id = get_id
+    @id = Addressable::URI.unescape(get_id)
     @ref, @path = extract_ref(@id)
     @repo = @project.repository
     if @options[:extended_sha1].blank?
diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb
index 4439775f612..9c115bbfc6a 100644
--- a/spec/lib/extracts_path_spec.rb
+++ b/spec/lib/extracts_path_spec.rb
@@ -29,6 +29,16 @@ describe ExtractsPath do
       assign_ref_vars
       expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb")
     end
+
+    context 'escaped sequences in ref' do
+      let(:ref) { "improve%2Fawesome" }
+
+      it "id should have no escape sequences" 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
   end
 
   describe '#extract_ref' do
-- 
GitLab