Ruby 1.9 compat: url helper encoding
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8463 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
a1ec3aa6c0
commit
8931a6ec16
|
@ -389,9 +389,8 @@ module ActionView
|
||||||
email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot")
|
email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot")
|
||||||
|
|
||||||
if encode == "javascript"
|
if encode == "javascript"
|
||||||
tmp = "document.write('#{content_tag("a", name || email_address, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');"
|
"document.write('#{content_tag("a", name || email_address, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|
|
||||||
for i in 0...tmp.length
|
string << sprintf("%%%x", c)
|
||||||
string << sprintf("%%%x",tmp[i])
|
|
||||||
end
|
end
|
||||||
"<script type=\"#{Mime::JS}\">eval(unescape('#{string}'))</script>"
|
"<script type=\"#{Mime::JS}\">eval(unescape('#{string}'))</script>"
|
||||||
elsif encode == "hex"
|
elsif encode == "hex"
|
||||||
|
@ -403,12 +402,9 @@ module ActionView
|
||||||
protocol = 'mailto:'
|
protocol = 'mailto:'
|
||||||
protocol.each_byte { |c| string << sprintf("&#%d;", c) }
|
protocol.each_byte { |c| string << sprintf("&#%d;", c) }
|
||||||
|
|
||||||
for i in 0...email_address.length
|
email_address.each_byte do |c|
|
||||||
if email_address[i,1] =~ /\w/
|
char = c.chr
|
||||||
string << sprintf("%%%x",email_address[i])
|
string << (char =~ /\w/ ? sprintf("%%%x", c) : char)
|
||||||
else
|
|
||||||
string << email_address[i,1]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
content_tag "a", name || email_address_encoded, html_options.merge({ "href" => "#{string}#{extras}" })
|
content_tag "a", name || email_address_encoded, html_options.merge({ "href" => "#{string}#{extras}" })
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue