Skip to content

Commit

Permalink
Ruby 1.9 compat: url helper encoding
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8463 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Dec 21, 2007
1 parent a1ec3aa commit 8931a6e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions actionpack/lib/action_view/helpers/url_helper.rb
Expand Up @@ -389,9 +389,8 @@ def mail_to(email_address, name = nil, html_options = {})
email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot")

if encode == "javascript"
tmp = "document.write('#{content_tag("a", name || email_address, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');"
for i in 0...tmp.length
string << sprintf("%%%x",tmp[i])
"document.write('#{content_tag("a", name || email_address, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|
string << sprintf("%%%x", c)
end
"<script type=\"#{Mime::JS}\">eval(unescape('#{string}'))</script>"
elsif encode == "hex"
Expand All @@ -403,12 +402,9 @@ def mail_to(email_address, name = nil, html_options = {})
protocol = 'mailto:'
protocol.each_byte { |c| string << sprintf("&#%d;", c) }

for i in 0...email_address.length
if email_address[i,1] =~ /\w/
string << sprintf("%%%x",email_address[i])
else
string << email_address[i,1]
end
email_address.each_byte do |c|
char = c.chr
string << (char =~ /\w/ ? sprintf("%%%x", c) : char)
end
content_tag "a", name || email_address_encoded, html_options.merge({ "href" => "#{string}#{extras}" })
else
Expand Down

0 comments on commit 8931a6e

Please sign in to comment.