1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_enc_cr_str_buf_cat): concatenation of valid

encoding string and invalid encoding string should result
  invalid encoding.  [ruby-core:33027]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-11-03 05:13:54 +00:00
parent f6b2490fdb
commit 742d440cba
3 changed files with 20 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Wed Nov 3 14:13:46 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_enc_cr_str_buf_cat): concatenation of valid
encoding string and invalid encoding string should result
invalid encoding. [ruby-core:33027]
Wed Nov 3 08:58:59 2010 Koichi Sasada <ko1@atdot.net>
* gc.c, vm.c, vm_core.h: remove USE_VALUE_CACHE option.

View file

@ -1905,7 +1905,10 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
}
else if (str_cr == ENC_CODERANGE_VALID) {
res_encindex = str_encindex;
res_cr = str_cr;
if (ptr_cr == ENC_CODERANGE_7BIT || ptr_cr == ENC_CODERANGE_VALID)
res_cr = str_cr;
else
res_cr = ptr_cr;
}
else { /* str_cr == ENC_CODERANGE_BROKEN */
res_encindex = str_encindex;

View file

@ -1299,6 +1299,16 @@ class TestM17N < Test::Unit::TestCase
s = "\xa1\xa1\x8f".force_encoding("euc-jp")
assert_equal(false, s.valid_encoding?)
assert_equal(true, s.reverse.valid_encoding?)
bug4018 = '[ruby-core:33027]'
s = "\xa1\xa1".force_encoding("euc-jp")
assert_equal(true, s.valid_encoding?)
s << "\x8f".force_encoding("euc-jp")
assert_equal(false, s.valid_encoding?, bug4018)
s = "aa".force_encoding("utf-16be")
assert_equal(true, s.valid_encoding?)
s << "\xff".force_encoding("utf-16be")
assert_equal(false, s.valid_encoding?, bug4018)
end
def test_getbyte