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:
authorMarin Jankovski <marin@gitlab.com>2014-05-20 17:58:30 +0400
committerMarin Jankovski <marin@gitlab.com>2014-05-26 22:43:58 +0400
commit603e04bc21b07b8b6f70e972383ea2f29d0bfce0 (patch)
treecb0adcdb8ce05f7a58c3d11ed7de79f33ed94bcd
parent52c3179be94e857ecb0de2cfa8ecbd484a36d213 (diff)
Make sure slashes are handled properly.
-rw-r--r--app/helpers/gitlab_markdown_helper.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 2d226adb2a4..b8891d801aa 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -102,6 +102,8 @@ module GitlabMarkdownHelper
path.gsub!(/(#.*)/, "")
id = $1 || ""
file_path = relative_file_path(path)
+ file_path = sanitize_slashes(file_path)
+
[
Gitlab.config.gitlab.relative_url_root,
@project.path_with_namespace,
@@ -110,6 +112,12 @@ module GitlabMarkdownHelper
].compact.join("/").gsub(/^\/*|\/*$/, '') + id
end
+ def sanitize_slashes(path)
+ path[0] = "" if path.start_with?("/")
+ path.chop if path.end_with?("/")
+ path
+ end
+
def relative_file_path(path)
requested_path = @path
nested_path = build_nested_path(path, requested_path)