diff options
author | Vasiliy Ermolovich <younash@gmail.com> | 2012-05-16 21:04:31 +0300 |
---|---|---|
committer | Vasiliy Ermolovich <younash@gmail.com> | 2012-05-16 21:05:26 +0300 |
commit | 9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054 (patch) | |
tree | 5169240dca52d916d392fbfc5ebebc5f9312f69c /activesupport/test | |
parent | e29626901ad82bafeb7ade13c3681aa777d7fe2a (diff) | |
download | rails-9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054.tar.gz rails-9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054.tar.bz2 rails-9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054.zip |
fix safe string interpolation with SafeBuffer#%, closes #6352
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 9010a4a716..eee2caa60e 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -439,6 +439,30 @@ class OutputSafetyTest < ActiveSupport::TestCase assert @other_string.html_safe? end + test "Concatting safe onto unsafe with % yields unsafe" do + @other_string = "other%s" + string = @string.html_safe + + @other_string = @other_string % string + assert !@other_string.html_safe? + end + + test "Concatting unsafe onto safe with % yields escaped safe" do + @other_string = "other%s".html_safe + string = @other_string % "<foo>" + + assert_equal "other<foo>", string + assert string.html_safe? + end + + test "Concatting safe onto safe with % yields safe" do + @other_string = "other%s".html_safe + string = @string.html_safe + + @other_string = @other_string % string + assert @other_string.html_safe? + end + test "Concatting a fixnum to safe always yields safe" do string = @string.html_safe string = string.concat(13) |