diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-21 11:51:01 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-21 11:51:01 +0000 |
commit | 8931a6ec16db78cf7ad8ffd0ca1ebec1694f9700 (patch) | |
tree | 46aadf3028942b0c9de4c192f308f4e4b40c4836 /actionpack/lib/action_view | |
parent | a1ec3aa6c0e948bfa6e6129b8e60bd38aab46892 (diff) | |
download | rails-8931a6ec16db78cf7ad8ffd0ca1ebec1694f9700.tar.gz rails-8931a6ec16db78cf7ad8ffd0ca1ebec1694f9700.tar.bz2 rails-8931a6ec16db78cf7ad8ffd0ca1ebec1694f9700.zip |
Ruby 1.9 compat: url helper encoding
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8463 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/url_helper.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index eb3391180e..253ab45420 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -389,9 +389,8 @@ module ActionView 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" @@ -403,12 +402,9 @@ module ActionView 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 |