Escape href attribute in auto links (#5179).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3612 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2010-03-24 20:26:22 +00:00
parent 84dfff5957
commit 8cdcf308be
3 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -825,7 +825,7 @@ class RedCloth3 < String
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
@@ -21,6 +21,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]
@@ -134,7 +135,8 @@ module Redmine
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
@@ -146,7 +148,7 @@ module Redmine
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