Skip to content

Commit

Permalink
Merged r3612 from trunk.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3661 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Apr 11, 2010
1 parent 390eb78 commit eb55efd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/redcloth3.rb
Expand Up @@ -818,7 +818,7 @@ def inline_textile_link( text )
post = ")"+post # add closing parenth to post
end
atts = pba( atts )
atts = " href=\"#{ url }#{ slash }\"#{ atts }"
atts = " href=\"#{ htmlesc url }#{ slash }\"#{ atts }"
atts << " title=\"#{ htmlesc title }\"" if title
atts = shelve( atts ) if atts

Expand Down
6 changes: 4 additions & 2 deletions lib/redmine/wiki_formatting/textile/formatter.rb
Expand Up @@ -22,6 +22,7 @@ module Redmine
module WikiFormatting
module Textile
class Formatter < RedCloth3
include ActionView::Helpers::TagHelper

# auto_link rule after textile rules so that it doesn't break !image_url! tags
RULES = [:textile, :block_markdown_rule, :inline_auto_link, :inline_auto_mailto, :inline_toc, :inline_macros]
Expand Down Expand Up @@ -162,7 +163,8 @@ def inline_auto_link(text)
url=url[0..-2] # discard closing parenth from url
post = ")"+post # add closing parenth to post
end
%(#{leading}<a class="external" href="#{proto=="www."?"http://www.":proto}#{url}">#{proto + url}</a>#{post})
tag = content_tag('a', proto + url, :href => "#{proto=="www."?"http://www.":proto}#{url}", :class => 'external')
%(#{leading}#{tag}#{post})
end
end
end
Expand All @@ -174,7 +176,7 @@ def inline_auto_mailto(text)
if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
mail
else
%{<a href="mailto:#{mail}" class="email">#{mail}</a>}
content_tag('a', mail, :href => "mailto:#{mail}", :class => "email")
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion test/unit/helpers/application_helper_test.rb
Expand Up @@ -59,12 +59,14 @@ def test_auto_links
'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>',
# two exclamation marks
'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>',
# escaping
'http://foo"bar' => '<a class="external" href="http://foo&quot;bar">http://foo"bar</a>',
}
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end

def test_auto_mailto
assert_equal '<p><a href="mailto:test@foo.bar" class="email">test@foo.bar</a></p>',
assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>',
textilizable('test@foo.bar')
end

Expand Down Expand Up @@ -129,6 +131,8 @@ def test_textile_external_links
"\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
# two exclamation marks
'"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>',
# escaping
'"test":http://foo"bar' => '<a href="http://foo&quot;bar" class="external">test</a>',
}
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
Expand Down

0 comments on commit eb55efd

Please sign in to comment.