mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Quote prepared statements of sanitize_sql_array
Sure unquoted SQL code pass test, but this % style prepared statements are dangerous. Test codes and code examples are also "Rails" codes, so quote placeholder of prepared statements.
This commit is contained in:
parent
4a375a83de
commit
14d265217a
1 changed files with 4 additions and 4 deletions
|
@ -9,11 +9,11 @@ class SanitizeTest < ActiveRecord::TestCase
|
|||
|
||||
def test_sanitize_sql_array_handles_string_interpolation
|
||||
quoted_bambi = ActiveRecord::Base.connection.quote_string("Bambi")
|
||||
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi"])
|
||||
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi".mb_chars])
|
||||
assert_equal "name='#{quoted_bambi}'", Binary.send(:sanitize_sql_array, ["name='%s'", "Bambi"])
|
||||
assert_equal "name='#{quoted_bambi}'", Binary.send(:sanitize_sql_array, ["name='%s'", "Bambi".mb_chars])
|
||||
quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote_string("Bambi\nand\nThumper")
|
||||
assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper"])
|
||||
assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper".mb_chars])
|
||||
assert_equal "name='#{quoted_bambi_and_thumper}'",Binary.send(:sanitize_sql_array, ["name='%s'", "Bambi\nand\nThumper"])
|
||||
assert_equal "name='#{quoted_bambi_and_thumper}'",Binary.send(:sanitize_sql_array, ["name='%s'", "Bambi\nand\nThumper".mb_chars])
|
||||
end
|
||||
|
||||
def test_sanitize_sql_array_handles_bind_variables
|
||||
|
|
Loading…
Reference in a new issue