summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-09-18 05:07:22 +0000
committerGo MAEDA <maeda@farend.jp>2023-09-18 05:07:22 +0000
commit5e07a7241392a82586054613896e4da73069bcbb (patch)
tree175c7c211eefd29e3b73c972ad02206eaa064847 /lib
parent4973c9014b571dd7f49b834907906e21c17f08a0 (diff)
downloadredmine-5e07a7241392a82586054613896e4da73069bcbb.tar.gz
redmine-5e07a7241392a82586054613896e4da73069bcbb.zip
Adapt markdown autolink behavior to that of common_mark (#38806).
Patch by Holger Just. git-svn-id: https://svn.redmine.org/redmine/trunk@22298 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/wiki_formatting/markdown/formatter.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/redmine/wiki_formatting/markdown/formatter.rb b/lib/redmine/wiki_formatting/markdown/formatter.rb
index 906f8c8a7..ac600179e 100644
--- a/lib/redmine/wiki_formatting/markdown/formatter.rb
+++ b/lib/redmine/wiki_formatting/markdown/formatter.rb
@@ -26,11 +26,24 @@ module Redmine
include ActionView::Helpers::TagHelper
include Redmine::Helpers::URL
+ def autolink(link, link_type)
+ if link_type == :email
+ link("mailto:#{link}", nil, link) || CGI.escapeHTML(link)
+ else
+ content = link
+ # Pretty printing: if we get an email address as an actual URI, e.g.
+ # `mailto:foo@bar.com`, we don't want to print the `mailto:` prefix
+ content = link[7..-1] if link.start_with?('mailto:')
+
+ link(link, nil, content) || CGI.escapeHTML(link)
+ end
+ end
+
def link(link, title, content)
- return nil unless uri_with_safe_scheme?(link)
+ return nil unless uri_with_link_safe_scheme?(link)
css = nil
- unless link && link.starts_with?('/')
+ unless link&.starts_with?('/') || link&.starts_with?('mailto:')
css = 'external'
end
content_tag('a', content.to_s.html_safe, :href => link, :title => title, :class => css)