aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-10-20 16:50:01 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-10-20 16:50:01 -0600
commitd94ae72a5259c31ea510e6341bbbf4e920312ebe (patch)
treea9bef1bd954692396f1af545d87dac207362d82c /activesupport/test
parentcd46bfc54fb34f0b4ed89e00d2efbe8a0273ab0b (diff)
parent05a2a6a0c5ac2384e52df9b8c2aa81352a51d7c7 (diff)
downloadrails-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.rb10
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 + "&lt;"
+ string = "\251 <"
+ expected = "© &lt;"
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 = "© &lt;"
+ assert_equal expected, ERB::Util.html_escape_once(string)
+ end
end
class StringExcludeTest < ActiveSupport::TestCase