summaryrefslogtreecommitdiff
path: root/lib/banzai
diff options
context:
space:
mode:
authorwinniehell <git@winniehell.de>2016-12-06 01:29:43 +0100
committerwinniehell <git@winniehell.de>2016-12-12 14:45:08 +0100
commit17e3d3fde8c9a83f58d797c5f62f36b59eedd870 (patch)
tree2593d642d5542760b241a66c959960dcf9333917 /lib/banzai
parent7a9ba9bb85c1ab0e4bb4f116ce45b9a82aea3096 (diff)
downloadgitlab-ce-17e3d3fde8c9a83f58d797c5f62f36b59eedd870.tar.gz
Avoid escaping relative links in Markdown twice (!7940)
Diffstat (limited to 'lib/banzai')
-rw-r--r--lib/banzai/filter/relative_link_filter.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index f09d78be0ce..9e23c8f8c55 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -46,7 +46,7 @@ module Banzai
end
def rebuild_relative_uri(uri)
- file_path = relative_file_path(uri.path)
+ file_path = relative_file_path(uri)
uri.path = [
relative_url_root,
@@ -59,8 +59,10 @@ module Banzai
uri
end
- def relative_file_path(path)
- nested_path = build_relative_path(path, context[:requested_path])
+ def relative_file_path(uri)
+ path = Addressable::URI.unescape(uri.path)
+ request_path = Addressable::URI.unescape(context[:requested_path])
+ nested_path = build_relative_path(path, request_path)
file_exists?(nested_path) ? nested_path : path
end
@@ -108,11 +110,7 @@ module Banzai
end
def uri_type(path)
- @uri_types[path] ||= begin
- unescaped_path = Addressable::URI.unescape(path)
-
- current_commit.uri_type(unescaped_path)
- end
+ @uri_types[path] ||= current_commit.uri_type(path)
end
def current_commit