summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-05 08:45:51 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-05 08:45:51 +0000
commit31b4094a556b9769b0b70e1f8413c1d1360806b0 (patch)
tree05eda73587c46a0d7cbedad281da8c6a07fa2b53 /test
parentaa2b685e2ddaddc65afb0235baacbca25015d38c (diff)
downloadruby-31b4094a556b9769b0b70e1f8413c1d1360806b0.tar.gz
ruby-31b4094a556b9769b0b70e1f8413c1d1360806b0.tar.xz
ruby-31b4094a556b9769b0b70e1f8413c1d1360806b0.zip
Web Mar 5 17:43:43 2008 Martin Duerst <duerst@it.aoyama.ac.jp>
* transcode.c (transcode_loop): Adjusted detection of invalid (ill-formed) UTF-8 sequences. Fixing potential security issue, see http://www.unicode.org/versions/Unicode5.1.0/#Notable_Changes. * test/ruby/test_transcode.rb: Added two tests for above fix. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_transcode.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb
index 9edf30882..5a704fd36 100644
--- a/test/ruby/test_transcode.rb
+++ b/test/ruby/test_transcode.rb
@@ -242,6 +242,11 @@ class TestTranscode < Test::Unit::TestCase
def test_invalid_ignore
# arguments only
- 'abc'.encode('utf-8', invalid: :ignore)
+ assert_nothing_raised { 'abc'.encode('utf-8', invalid: :ignore) }
+ # check handling of UTF-8 ill-formed subsequences
+ assert_equal("\x00\x41\x00\x3E\x00\x42".force_encoding('UTF-16BE'),
+ "\x41\xC2\x3E\x42".encode('UTF-16BE', 'UTF-8', invalid: :ignore))
+ assert_equal("\x00\x41\x00\xF1\x00\x42".force_encoding('UTF-16BE'),
+ "\x41\xC2\xC3\xB1\x42".encode('UTF-16BE', 'UTF-8', invalid: :ignore))
end
end