@@ -152,12 +152,16 module Redmine | |||
|
152 | 152 | end |
|
153 | 153 | end |
|
154 | 154 | end |
|
155 | ||
|
155 | ||
|
156 | 156 | # Turns all email addresses into clickable links (code from Rails). |
|
157 | 157 | def inline_auto_mailto(text) |
|
158 | 158 | text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do |
|
159 |
|
|
|
160 | %{<a href="mailto:#{$1}" class="email">#{text}</a>} | |
|
159 | mail = $1 | |
|
160 | if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/) | |
|
161 | ||
|
162 | else | |
|
163 | %{<a href="mailto:#{mail}" class="email">#{mail}</a>} | |
|
164 | end | |
|
161 | 165 | end |
|
162 | 166 | end |
|
163 | 167 | end |
@@ -34,7 +34,8 class ApplicationHelperTest < HelperTestCase | |||
|
34 | 34 | '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>.', |
|
35 | 35 | 'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>', |
|
36 | 36 | 'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>', |
|
37 | 'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>' | |
|
37 | 'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>', | |
|
38 | 'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>', | |
|
38 | 39 | } |
|
39 | 40 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
40 | 41 | end |
General Comments 0
You need to be logged in to leave comments.
Login now