summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-29 09:19:15 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-29 09:19:15 +0000
commit4574cf872b0efe4e0b6ef180a5e273fccf0b628e (patch)
tree5a7cfc28983ed2e26680686bc23eb47de95fa813 /string.c
parent8c2372933098e73a549e0c8ce7c9edc94c03e38a (diff)
downloadruby-4574cf872b0efe4e0b6ef180a5e273fccf0b628e.tar.gz
ruby-4574cf872b0efe4e0b6ef180a5e273fccf0b628e.tar.xz
ruby-4574cf872b0efe4e0b6ef180a5e273fccf0b628e.zip
* time.c (time_strftime): format should be ascii compatible.
* parse.y (rb_intern3): non ASCII compatible symbols. * re.c (rb_reg_regsub): add encoding check. * string.c (rb_str_chomp_bang): ditto. * test/ruby/test_utf16.rb (TestUTF16::test_chomp): raises exception. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/string.c b/string.c
index ffae4518e..1b88ded7b 100644
--- a/string.c
+++ b/string.c
@@ -5273,6 +5273,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
rs = rb_rs;
if (rs == rb_default_rs) {
smart_chomp:
+ rb_enc_check(str, rs);
rb_str_modify(str);
if (RSTRING_PTR(str)[len-1] == '\n') {
STR_DEC_LEN(str);
@@ -5648,6 +5649,11 @@ rb_str_scan(VALUE str, VALUE pat)
static VALUE
rb_str_hex(VALUE str)
{
+ rb_encoding *enc = rb_enc_get(str);
+
+ if (!rb_enc_asciicompat(enc)) {
+ rb_raise(rb_eArgError, "ASCII incompatible encoding: %s", rb_enc_name(enc));
+ }
return rb_str_to_inum(str, 16, Qfalse);
}
@@ -5669,6 +5675,11 @@ rb_str_hex(VALUE str)
static VALUE
rb_str_oct(VALUE str)
{
+ rb_encoding *enc = rb_enc_get(str);
+
+ if (!rb_enc_asciicompat(enc)) {
+ rb_raise(rb_eArgError, "ASCII incompatible encoding: %s", rb_enc_name(enc));
+ }
return rb_str_to_inum(str, -8, Qfalse);
}