From 183bbd8b69077ff98c2c39f5ebc61ffe60725786 Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 29 Dec 2010 09:24:37 +0000 Subject: [PATCH] Sorry, commit miss of r30412. * re.c (rb_reg_expr_str): need to escape if the coderage is invalid. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++-- re.c | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c400fdb1d2..1c767078bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Dec 29 18:23:46 2010 NAKAMURA Usaku + + * re.c (rb_reg_expr_str): need to escape if the coderage is invalid. + Wed Dec 29 10:06:51 2010 Tanaka Akira * signal.c: parenthesize macro arguments. @@ -12,8 +16,6 @@ Wed Dec 29 07:07:06 2010 Eric Hodel Tue Dec 28 18:36:38 2010 NAKAMURA Usaku - * re.c (rb_reg_expr_str): need to escape if the coderage is invalid. - * error.c, include/ruby/intern.h (rb_compile_error_with_enc): new function to raise syntax error, with source encoding'ed message. diff --git a/re.c b/re.c index 047acb62f9..2157ee8764 100644 --- a/re.c +++ b/re.c @@ -321,11 +321,14 @@ rb_reg_expr_str(VALUE str, const char *s, long len, rb_encoding *enc, rb_encoding *resenc) { const char *p, *pend; + int cr = ENC_CODERANGE_UNKNOWN; int need_escape = 0; int c, clen; p = s; pend = p + len; - if (rb_enc_asciicompat(enc)) { + rb_str_coderange_scan_restartable(p, pend, enc, &cr); + if (rb_enc_asciicompat(enc) && + (cr == ENC_CODERANGE_VALID || cr == ENC_CODERANGE_7BIT)) { while (p < pend) { c = rb_enc_ascget(p, pend, &clen, enc); if (c == -1) {