]> source.dussan.org Git - redmine.git/commitdiff
Fixed: urls containing @ are parsed as email adress by the wiki formatter (#1456).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 17 Jun 2008 19:27:03 +0000 (19:27 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 17 Jun 2008 19:27:03 +0000 (19:27 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1559 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting.rb
test/unit/helpers/application_helper_test.rb

index 88a858b0458d1ed96f1e3810cbdb22b4e27d3e88..6c8eebbbc418bc9dae079f52ee71fad4673e9410 100644 (file)
@@ -152,12 +152,16 @@ module Redmine
           end
         end
       end
-      
+
       # Turns all email addresses into clickable links (code from Rails).
       def inline_auto_mailto(text)
         text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
-          text = $1
-          %{<a href="mailto:#{$1}" class="email">#{text}</a>}
+          mail = $1
+          if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
+            mail
+          else
+            %{<a href="mailto:#{mail}" class="email">#{mail}</a>}
+          end
         end
       end
     end
index c6afdda0e401ddf48112636918177688876a66e8..9504a8c797a044fdbf3d7dd5b82bab8923644591 100644 (file)
@@ -34,7 +34,8 @@ class ApplicationHelperTest < HelperTestCase
       'http://foo.bar/foo.bar#foo.bar.' => '<a class="external" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.',
       'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
       'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&#38;t=z&#38;s=">http://foo.bar/page?p=1&#38;t=z&#38;s=</a>',
-      'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>'
+      'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
+      'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
     }
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
   end