summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-16 16:26:04 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-16 16:26:04 +0000
commit4f78e7fff4949f5c94d35bce6b610d1188fd7c27 (patch)
tree71b824f19970d48f1af8718d703ef14fb4103227
parent0b6a0045aaf8de72b4ce39fe117b2ba88ccdcc15 (diff)
* parse.y (rb_intern3): prohibit Symbol with an invalid encoding.
[ruby-core:24621] * test/ruby/test_m17n_comb.rb: modify a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--NEWS1
-rw-r--r--parse.y4
-rw-r--r--test/ruby/test_m17n_comb.rb4
4 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 33c6d125e5..64b7f0a0c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Mar 17 01:24:01 2010 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * parse.y (rb_intern3): prohibit Symbol with an invalid encoding.
+ [ruby-core:24621]
+
+ * test/ruby/test_m17n_comb.rb: modify a test for above.
+
Tue Mar 16 22:51:11 2010 Tanaka Akira <akr@fsij.org>
* tool/transcode-tblgen.rb: specialize for singletom mappings.
diff --git a/NEWS b/NEWS
index 56b4cf6833..0b6a946b74 100644
--- a/NEWS
+++ b/NEWS
@@ -313,6 +313,7 @@ with all sufficient information, see the ChangeLog file.
* \d, \s, and \w are now ASCII only; use POSIX bracket classes and \p{} for
Unicode semantics
* $: no longer includes the current directory, use require_relative
+* Symbol with an invalid encoding is forbidden to exist.
=== Compilation options
diff --git a/parse.y b/parse.y
index e338c6fa38..6a0e431083 100644
--- a/parse.y
+++ b/parse.y
@@ -9505,6 +9505,10 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
str = (VALUE)&fake_str;
rb_enc_associate(str, enc);
+ if (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN) {
+ rb_raise(rb_eEncodingError, "invalid encoding symbol");
+ }
+
if (st_lookup(global_symbols.sym_id, str, (st_data_t *)&id))
return id;
diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb
index ab891363b1..cf80377172 100644
--- a/test/ruby/test_m17n_comb.rb
+++ b/test/ruby/test_m17n_comb.rb
@@ -1040,10 +1040,12 @@ class TestM17NComb < Test::Unit::TestCase
STRINGS.each {|s|
if /\0/ =~ a(s)
assert_raise(ArgumentError) { s.intern }
- else
+ elsif s.valid_encoding?
sym = s.intern
assert_equal(s, sym.to_s, "#{encdump s}.intern.to_s")
assert_equal(sym, s.to_sym)
+ else
+ assert_raise(EncodingError) { s.intern }
end
}
end