diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-20 16:50:01 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-20 16:50:01 -0600 |
commit | d94ae72a5259c31ea510e6341bbbf4e920312ebe (patch) | |
tree | a9bef1bd954692396f1af545d87dac207362d82c /activesupport/test | |
parent | cd46bfc54fb34f0b4ed89e00d2efbe8a0273ab0b (diff) | |
parent | 05a2a6a0c5ac2384e52df9b8c2aa81352a51d7c7 (diff) | |
download | rails-d94ae72a5259c31ea510e6341bbbf4e920312ebe.tar.gz rails-d94ae72a5259c31ea510e6341bbbf4e920312ebe.tar.bz2 rails-d94ae72a5259c31ea510e6341bbbf4e920312ebe.zip |
Merge pull request #19992 from greysteil/handle-invalid-utf8-in-html-escape
Handle invalid UTF-8 strings when HTML escaping
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 3a5d6df06d..9cc7bb1a77 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -782,8 +782,8 @@ class OutputSafetyTest < ActiveSupport::TestCase end test "ERB::Util.html_escape should correctly handle invalid UTF-8 strings" do - string = [192, 60].pack('CC') - expected = 192.chr + "<" + string = "\251 <" + expected = "© <" assert_equal expected, ERB::Util.html_escape(string) end @@ -799,6 +799,12 @@ class OutputSafetyTest < ActiveSupport::TestCase assert_equal escaped_string, ERB::Util.html_escape_once(string) assert_equal escaped_string, ERB::Util.html_escape_once(escaped_string) end + + test "ERB::Util.html_escape_once should correctly handle invalid UTF-8 strings" do + string = "\251 <" + expected = "© <" + assert_equal expected, ERB::Util.html_escape_once(string) + end end class StringExcludeTest < ActiveSupport::TestCase |