summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-05 01:38:36 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-05 01:38:36 +0000
commit88c0b8fec94c192033c9522e7edc64ea2fb960e4 (patch)
treeddcaa0743db9a28a56e35a05a646b0c58edcbf12
parent93b9f2cc5ef029d4cdeab7637fd419580af57d79 (diff)
Fix error message of /.../n with embeded non ASCII-8BIT string.
* re.c (rb_reg_preprocess_dregexp): add options to arguments. * re.c (rb_reg_new_ary): follow above. * re.c (rb_reg_preprocess_dregexp): change error message when /.../n has a non escaped non ASCII character in non ASCII-8BIT script. [ruby-dev:38524] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog14
-rw-r--r--re.c13
2 files changed, 22 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 35b939ea2e8..2ee3d4c9bc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,20 @@
+Wed Aug 5 10:20:39 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * re.c (rb_reg_preprocess_dregexp): add options to arguments.
+
+ * re.c (rb_reg_new_ary): follow above.
+
+ * re.c (rb_reg_preprocess_dregexp): change error message when
+ /.../n has a non escaped non ASCII character in non ASCII-8BIT
+ script. [ruby-dev:38524]
+
Wed Aug 5 03:28:41 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit.rb (Test::Unit.setup_argv): expands paths before
requiring. [ruby-dev:39012]
Wed Aug 5 01:38:27 2009 Yusuke Endoh <mame@tsg.ne.jp>
-
+
* lib/pp.rb (guard_inspect_key): untrust internal hash to prevent
unexpected SecurityError.
@@ -534,7 +544,7 @@ Tue Jul 21 21:37:19 2009 Keiju Ishitsuka <keiju@ruby-lang.org>
* lib/irb/cmd/help.rb: fixed irb's "help" command. [ruby-core:22310].
* lib/tracer.rb: no show lines unkonwn line number. [ruby-core:22096],
- no trace display c-call and c-return as default.
+ no trace display c-call and c-return as default.
Tue Jul 21 16:24:41 2009 Masaki Suketa <masaki.suketa@nifty.ne.jp>
diff --git a/re.c b/re.c
index 7ccb46cc04f..4fb8b413519 100644
--- a/re.c
+++ b/re.c
@@ -2264,13 +2264,14 @@ rb_reg_check_preprocess(VALUE str)
}
static VALUE
-rb_reg_preprocess_dregexp(VALUE ary)
+rb_reg_preprocess_dregexp(VALUE ary, int options)
{
rb_encoding *fixed_enc = 0;
rb_encoding *regexp_enc = 0;
onig_errmsg_buffer err = "";
int i;
VALUE result = 0;
+ rb_encoding *ascii8bit = rb_ascii8bit_encoding();
if (RARRAY_LEN(ary) == 0) {
rb_raise(rb_eArgError, "no arguments given");
@@ -2282,10 +2283,16 @@ rb_reg_preprocess_dregexp(VALUE ary)
char *p, *end;
rb_encoding *src_enc;
+ src_enc = rb_enc_get(str);
+ if (options & ARG_ENCODING_NONE &&
+ src_enc != ascii8bit &&
+ rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
+ rb_raise(rb_eRegexpError, "/.../n has a non escaped non ASCII character in non ASCII-8BIT script");
+ }
+
StringValue(str);
p = RSTRING_PTR(str);
end = p + RSTRING_LEN(str);
- src_enc = rb_enc_get(str);
buf = rb_reg_preprocess(p, end, src_enc, &fixed_enc, err);
@@ -2421,7 +2428,7 @@ rb_reg_new_str(VALUE s, int options)
VALUE
rb_reg_new_ary(VALUE ary, int opt)
{
- return rb_reg_new_str(rb_reg_preprocess_dregexp(ary), opt);
+ return rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
}
VALUE