ruby-changes:12683
From: naruse <ko1@a...>
Date: Wed, 5 Aug 2009 10:40:53 +0900 (JST)
Subject: [ruby-changes:12683] Ruby:r24398 (trunk): Fix error message of /.../n with embeded non ASCII-8BIT string.
naruse 2009-08-05 10:38:36 +0900 (Wed, 05 Aug 2009) New Revision: 24398 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24398 Log: 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] Modified files: trunk/ChangeLog trunk/re.c Index: ChangeLog =================================================================== --- ChangeLog (revision 24397) +++ ChangeLog (revision 24398) @@ -1,3 +1,13 @@ +Wed Aug 5 10:20:39 2009 NARUSE, Yui <naruse@r...> + + * 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@r...> * lib/test/unit.rb (Test::Unit.setup_argv): expands paths before @@ -4,7 +14,7 @@ requiring. [ruby-dev:39012] Wed Aug 5 01:38:27 2009 Yusuke Endoh <mame@t...> - + * lib/pp.rb (guard_inspect_key): untrust internal hash to prevent unexpected SecurityError. @@ -534,7 +544,7 @@ * 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@n...> Index: re.c =================================================================== --- re.c (revision 24397) +++ re.c (revision 24398) @@ -2264,13 +2264,14 @@ } 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 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/