]> source.dussan.org Git - redmine.git/commitdiff
Email addresses with slashes are not linked correctly (#19735).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 8 May 2015 07:03:00 +0000 (07:03 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 8 May 2015 07:03:00 +0000 (07:03 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@14237 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting.rb
test/unit/lib/redmine/wiki_formatting_test.rb

index 4ea59336d235c659f19fc80997fff230299aaaac..c4e4bb7c387cc4175578e25c09cba9e9c81a39ff 100644 (file)
@@ -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(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
             mail
index 413905db930cca319d263bc15b6183716df43f6a..cd7f40e7337376aa81b9cc23d3236c650cb2b16d 100644 (file)
@@ -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 = '<p><a class="email" href="mailto:foo/bar@example.net">foo/bar@example.net</a></p>'
+    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