Commit ca9aca92 authored by Douwe Maan's avatar Douwe Maan

Allow smb:// links in Markdown text.

parent e0caed91
...@@ -119,7 +119,7 @@ module GitlabMarkdownHelper ...@@ -119,7 +119,7 @@ module GitlabMarkdownHelper
end end
def ignored_protocols def ignored_protocols
["http://","https://", "ftp://", "mailto:"] ["http://","https://", "ftp://", "mailto:", "smb://"]
end end
def rebuild_path(file_path) def rebuild_path(file_path)
......
...@@ -50,6 +50,8 @@ module Gitlab ...@@ -50,6 +50,8 @@ module Gitlab
# Version of your assets, change this if you want to expire all your assets # Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0' config.assets.version = '1.0'
config.action_view.sanitized_allowed_protocols = %w(smb)
# Relative url support # Relative url support
# Uncomment and customize the last line to run in a non-root path # 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. # WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this.
......
...@@ -10,6 +10,12 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -10,6 +10,12 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
super options super options
end 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 # If project has issue number 39, apostrophe will be linked in
# regular text to the issue as Redcarpet will convert apostrophe to # regular text to the issue as Redcarpet will convert apostrophe to
# #39; # #39;
...@@ -54,6 +60,8 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -54,6 +60,8 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end end
def postprocess(full_document) def postprocess(full_document)
full_document.gsub!("ftp://smb:", "smb://")
full_document.gsub!("&rsquo;", "'") full_document.gsub!("&rsquo;", "'")
unless @template.instance_variable_get("@project_wiki") || @project.nil? unless @template.instance_variable_get("@project_wiki") || @project.nil?
full_document = h.create_relative_links(full_document) full_document = h.create_relative_links(full_document)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment