From c4374cb960a08054bf6b92d375bc8ba9afd6c094 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 8 May 2015 07:03:00 +0000 Subject: [PATCH] Email addresses with slashes are not linked correctly (#19735). Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@14237 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/wiki_formatting.rb | 2 +- test/unit/lib/redmine/wiki_formatting_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 4ea59336d..c4e4bb7c3 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -135,7 +135,7 @@ module Redmine # Destructively replaces email addresses into clickable links def auto_mailto!(text) - text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do + text.gsub!(/([\w\.!#\$%\-+.\/]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do mail = $1 if text.match(/]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/) mail diff --git a/test/unit/lib/redmine/wiki_formatting_test.rb b/test/unit/lib/redmine/wiki_formatting_test.rb index 413905db9..cd7f40e73 100644 --- a/test/unit/lib/redmine/wiki_formatting_test.rb +++ b/test/unit/lib/redmine/wiki_formatting_test.rb @@ -48,6 +48,12 @@ EXPECTED assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '') end + def test_should_link_email_with_slashes + raw = 'foo/bar@example.net' + expected = '

' + assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '') + end + def test_links_separated_with_line_break_should_link raw = <<-DIFF link: https://www.redmine.org -- 2.39.5