mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
html_escape mail_to when encode javascript and not hex
Signed-off-by: Yehuda Katz <yehudakatz@YK.local>
This commit is contained in:
committed by
Yehuda Katz
parent
f86421fb28
commit
9f1900ec7a
@@ -469,14 +469,12 @@ module ActionView
|
||||
extras << "subject=#{Rack::Utils.escape(subject).gsub("+", "%20")}&" unless subject.nil?
|
||||
extras = "?" << extras.gsub!(/&?$/,"") unless extras.empty?
|
||||
|
||||
email_address = email_address.to_s
|
||||
|
||||
email_address_obfuscated = email_address.dup
|
||||
email_address_obfuscated = html_escape(email_address)
|
||||
email_address_obfuscated.gsub!(/@/, html_options.delete("replace_at")) if html_options.has_key?("replace_at")
|
||||
email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot")
|
||||
|
||||
if encode == "javascript"
|
||||
"document.write('#{content_tag("a", name || email_address_obfuscated, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|
|
||||
"document.write('#{content_tag("a", name || email_address_obfuscated.html_safe, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|
|
||||
string << sprintf("%%%x", c)
|
||||
end
|
||||
"<script type=\"#{Mime::JS}\">eval(decodeURIComponent('#{string}'))</script>"
|
||||
@@ -495,7 +493,7 @@ module ActionView
|
||||
end
|
||||
content_tag "a", name || email_address_encoded.html_safe, html_options.merge({ "href" => "#{string}#{extras}" })
|
||||
else
|
||||
content_tag "a", name || email_address_obfuscated, html_options.merge({ "href" => "mailto:#{email_address}#{extras}" })
|
||||
content_tag "a", name || email_address_obfuscated.html_safe, html_options.merge({ "href" => "mailto:#{email_address}#{extras}" })
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user