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