Commit 5e076bdf115789a0ab279f3b0ba9e4214020d669

Updated to lastest rails + a patch of our own (in url_helper, ticket #294)

Commit diff

spec/helpers/users_helper_spec.rb

 
1111 Need to investigate if this is a Rails bug and
1212 either fix it there or let go of obfuscation.
1313 }
14 pending(message) do
14 #pending(message) do
1515 email = "aAT@NOSPAM@bDOTcom"
1616 encoded = (0...email.length).inject("") do |result, index|
1717 result << sprintf("%%%x",email[index])
1818 end
1919 helper.encoded_mail_to("a@b.com").should match(/#{encoded}/)
20 end
20 #end
2121 end
2222end
toggle raw diff

vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb

 
444444 email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot")
445445
446446 if encode == "javascript"
447 "document.write('#{content_tag("a", name || email_address, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|
447 "document.write('#{content_tag("a", name || email_address_obfuscated, html_options.merge({ "href" => "mailto:"+email_address_obfuscated+extras }))}');".each_byte do |c|
448448 string << sprintf("%%%x", c)
449449 end
450450 "<script type=\"#{Mime::JS}\">eval(unescape('#{string}'))</script>"
toggle raw diff

vendor/rails/actionpack/test/template/url_helper_test.rb

 
283283 assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#40;&#97;&#116;&#41;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)")
284284 assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex", :replace_at => "(at)")
285285 assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#40;&#97;&#116;&#41;&#100;&#111;&#109;&#97;&#105;&#110;&#40;&#100;&#111;&#116;&#41;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)", :replace_dot => "(dot)")
286 assert_dom_equal "<script type=\"text/javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)")
286 assert_dom_equal "<script type=\"text/javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%28%61%74%29%64%6f%6d%61%69%6e%28%64%6f%74%29%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)")
287287 end
288288
289289 def protect_against_forgery?
toggle raw diff

vendor/rails/activerecord/CHANGELOG

 
1*Edge*
2
3* Added SQL escaping for :limit and :offset in MySQL [Jonathan Wiess]
4
5
16*2.1.0 (May 31st, 2008)*
27
38* Add ActiveRecord::Base.sti_name that checks ActiveRecord::Base#store_full_sti_class? and returns either the full or demodulized name. [rick]
toggle raw diff

vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

 
336336
337337 def add_limit_offset!(sql, options) #:nodoc:
338338 if limit = options[:limit]
339 limit = sanitize_limit(limit)
339340 unless offset = options[:offset]
340341 sql << " LIMIT #{limit}"
341342 else
342 sql << " LIMIT #{offset}, #{limit}"
343 sql << " LIMIT #{offset.to_i}, #{limit}"
343344 end
344345 end
345346 end
toggle raw diff

vendor/rails/activerecord/test/cases/adapter_test.rb

 
118118 sql_inject = "1, 7 procedure help()"
119119 if current_adapter?(:MysqlAdapter)
120120 assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject)
121 assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7)
121 assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=> '1 ; DROP TABLE USERS', :offset=>7)
122122 else
123123 assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject)
124124 assert_equal " LIMIT 1,7 OFFSET 7", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7)
toggle raw diff