diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-08 08:09:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-08 08:09:14 +0000 |
commit | 40236a58c6c9c10e9041a889eb843ee581c6b156 (patch) | |
tree | 5194a2d3fcace4493fae2646bed010b831ee3e26 | |
parent | 2f7d3b465325021f24460fefe3505b374653a018 (diff) |
merges r29676 from trunk into ruby_1_9_2.
--
* 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/branches/ruby_1_9_2@30132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | string.c | 5 | ||||
-rw-r--r-- | test/ruby/test_m17n.rb | 10 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 21 insertions, 2 deletions
@@ -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 07:47:25 2010 Yukihiro Matsumoto <matz@ruby-lang.org> * lib/irb/ruby-lex.rb (RubyLex#identify_string): parse multiple @@ -1884,7 +1884,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; diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 9f1419df7d..3682d09898 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1294,6 +1294,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 @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 86 +#define RUBY_PATCHLEVEL 87 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |