diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-12 03:57:52 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-12 03:57:52 +0000 |
commit | f29a7ce51f1f9d859258e190cf1d01c3d58806e1 (patch) | |
tree | d9c9fc124f0428d766d009c615f0ee823df9c081 | |
parent | 85e3b25c04f33a73886d6294a54045b8e71c3545 (diff) | |
parent | 11e966d7a93ec0a745cde65021fa79a6a6b24667 (diff) | |
download | gitlab-ce-f29a7ce51f1f9d859258e190cf1d01c3d58806e1.tar.gz |
Merge branch 'markdown-smb-link' into 'master'
Allow smb:// links in Markdown text.
As requested by Sam McLeod at https://gitlab.com/gitlab-org/gitlab-ce/issues/1184
See merge request !1669
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 2 | ||||
-rw-r--r-- | config/application.rb | 2 | ||||
-rw-r--r-- | lib/redcarpet/render/gitlab_html.rb | 8 |
4 files changed, 12 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index fef266d2eec..3b263a7d4fa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -60,6 +60,7 @@ v 7.8.4 v 7.8.3 - Bump version of gitlab_git fixing annotated tags without message + - Allow smb:// links in Markdown text. v 7.8.2 - Fix service migration issue when upgrading from versions prior to 7.3 diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index daaefe90f18..f8e104b0827 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -121,7 +121,7 @@ module GitlabMarkdownHelper end def ignored_protocols - ["http://","https://", "ftp://", "mailto:"] + ["http://","https://", "ftp://", "mailto:", "smb://"] end def rebuild_path(file_path) diff --git a/config/application.rb b/config/application.rb index bd4578848c5..fa399533e52 100644 --- a/config/application.rb +++ b/config/application.rb @@ -50,6 +50,8 @@ module Gitlab # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + config.action_view.sanitized_allowed_protocols = %w(smb) + # Relative url support # Uncomment and customize the last line to run in a non-root path # WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this. diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index 713d7c39a11..1cd3933e4b7 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -11,6 +11,12 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML super options end + def preprocess(full_document) + # Redcarpet doesn't allow SMB links when `safe_links_only` is enabled. + # FTP links are allowed, so we trick Redcarpet. + full_document.gsub("smb://", "ftp://smb:") + end + # If project has issue number 39, apostrophe will be linked in # regular text to the issue as Redcarpet will convert apostrophe to # #39; @@ -55,6 +61,8 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML end def postprocess(full_document) + full_document.gsub!("ftp://smb:", "smb://") + full_document.gsub!("’", "'") unless @template.instance_variable_get("@project_wiki") || @project.nil? full_document = h.create_relative_links(full_document) |