@@ -818,7 +818,7 class RedCloth3 < String | |||||
818 | post = ")"+post # add closing parenth to post |
|
818 | post = ")"+post # add closing parenth to post | |
819 | end |
|
819 | end | |
820 | atts = pba( atts ) |
|
820 | atts = pba( atts ) | |
821 | atts = " href=\"#{ url }#{ slash }\"#{ atts }" |
|
821 | atts = " href=\"#{ htmlesc url }#{ slash }\"#{ atts }" | |
822 | atts << " title=\"#{ htmlesc title }\"" if title |
|
822 | atts << " title=\"#{ htmlesc title }\"" if title | |
823 | atts = shelve( atts ) if atts |
|
823 | atts = shelve( atts ) if atts | |
824 |
|
824 |
@@ -22,6 +22,7 module Redmine | |||||
22 | module WikiFormatting |
|
22 | module WikiFormatting | |
23 | module Textile |
|
23 | module Textile | |
24 | class Formatter < RedCloth3 |
|
24 | class Formatter < RedCloth3 | |
|
25 | include ActionView::Helpers::TagHelper | |||
25 |
|
26 | |||
26 | # auto_link rule after textile rules so that it doesn't break !image_url! tags |
|
27 | # auto_link rule after textile rules so that it doesn't break !image_url! tags | |
27 | RULES = [:textile, :block_markdown_rule, :inline_auto_link, :inline_auto_mailto, :inline_toc, :inline_macros] |
|
28 | RULES = [:textile, :block_markdown_rule, :inline_auto_link, :inline_auto_mailto, :inline_toc, :inline_macros] | |
@@ -162,7 +163,8 module Redmine | |||||
162 | url=url[0..-2] # discard closing parenth from url |
|
163 | url=url[0..-2] # discard closing parenth from url | |
163 | post = ")"+post # add closing parenth to post |
|
164 | post = ")"+post # add closing parenth to post | |
164 | end |
|
165 | end | |
165 |
|
|
166 | tag = content_tag('a', proto + url, :href => "#{proto=="www."?"http://www.":proto}#{url}", :class => 'external') | |
|
167 | %(#{leading}#{tag}#{post}) | |||
166 | end |
|
168 | end | |
167 | end |
|
169 | end | |
168 | end |
|
170 | end | |
@@ -174,7 +176,7 module Redmine | |||||
174 | if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/) |
|
176 | if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/) | |
175 |
|
177 | |||
176 | else |
|
178 | else | |
177 |
|
|
179 | content_tag('a', mail, :href => "mailto:#{mail}", :class => "email") | |
178 | end |
|
180 | end | |
179 | end |
|
181 | end | |
180 | end |
|
182 | end |
@@ -59,12 +59,14 class ApplicationHelperTest < HelperTestCase | |||||
59 | 'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>', |
|
59 | 'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>', | |
60 | # two exclamation marks |
|
60 | # two exclamation marks | |
61 | 'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>', |
|
61 | 'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>', | |
|
62 | # escaping | |||
|
63 | 'http://foo"bar' => '<a class="external" href="http://foo"bar">http://foo"bar</a>', | |||
62 | } |
|
64 | } | |
63 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
65 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
64 | end |
|
66 | end | |
65 |
|
67 | |||
66 | def test_auto_mailto |
|
68 | def test_auto_mailto | |
67 |
assert_equal '<p><a href="mailto:test@foo.bar |
|
69 | assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>', | |
68 | textilizable('test@foo.bar') |
|
70 | textilizable('test@foo.bar') | |
69 | end |
|
71 | end | |
70 |
|
72 | |||
@@ -129,6 +131,8 RAW | |||||
129 | "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>", |
|
131 | "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>", | |
130 | # two exclamation marks |
|
132 | # two exclamation marks | |
131 | '"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>', |
|
133 | '"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>', | |
|
134 | # escaping | |||
|
135 | '"test":http://foo"bar' => '<a href="http://foo"bar" class="external">test</a>', | |||
132 | } |
|
136 | } | |
133 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
137 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
134 | end |
|
138 | end |
General Comments 0
You need to be logged in to leave comments.
Login now