1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

prohibit number backref in replaced string for named pattern

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosako 2006-03-23 12:43:51 +00:00
parent f69c1f18ee
commit 50091c990d
2 changed files with 13 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* re.c (rb_reg_regsub): prohibit \1, \2 ...\9 in replaced string
for named regex pattern.
Thu Mar 23 21:06:23 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* oniguruma.h: Version 4.0.2

10
re.c
View file

@ -2055,9 +2055,14 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
uc = (unsigned char)*s++;
p = s;
switch (uc) {
case '0': case '1': case '2': case '3': case '4':
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
no = uc - '0';
if (onig_noname_group_capture_is_active(RREGEXP(regexp)->ptr)) {
no = uc - '0';
}
else {
continue;
}
break;
case 'k':
@ -2083,6 +2088,7 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
rb_str_buf_cat(val, s-2, 2);
continue;
case '0':
case '&':
no = 0;
break;