diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-11 09:18:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-11 09:18:54 +0000 |
commit | d5507529fbcad12a37714a0a3f39d2f9f2e4b7ce (patch) | |
tree | 09c1328183e4ac51711b93522b53b7f0c62d5b4d /re.c | |
parent | a9987f8ce6ef8edee377e2bf4fc9b7a5b61a1045 (diff) | |
download | ruby-d5507529fbcad12a37714a0a3f39d2f9f2e4b7ce.tar.gz ruby-d5507529fbcad12a37714a0a3f39d2f9f2e4b7ce.tar.xz ruby-d5507529fbcad12a37714a0a3f39d2f9f2e4b7ce.zip |
* re.c (match_select): should propagate taintness.
* hash.c (rb_hash_set_default): Hash#default= should return the
new value.
* string.c (rb_str_to_i): accepts optional base argument. [new]
* numeric.c (rb_fix2str): should not handle negative fixnum values
int32 via calling sprintf() directly.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -829,6 +829,7 @@ match_select(argc, argv, match) VALUE result = rb_ary_new(); int i; long idx; + int taint = OBJ_TAINTED(match); for (i=0; i<argc; i++) { idx = NUM2LONG(argv[i]); @@ -837,8 +838,9 @@ match_select(argc, argv, match) rb_ary_push(result, Qnil); } else { - rb_ary_push(result, rb_str_new(ptr+regs->beg[idx], - regs->end[idx]-regs->beg[idx])); + VALUE str = rb_str_new(ptr+regs->beg[i], regs->end[i]-regs->beg[i]); + if (taint) OBJ_TAINT(str); + rb_ary_push(result, str); } } return result; @@ -981,15 +983,11 @@ static VALUE rb_reg_equal(re1, re2) VALUE re1, re2; { - int min; - if (re1 == re2) return Qtrue; if (TYPE(re2) != T_REGEXP) return Qfalse; rb_reg_check(re1); rb_reg_check(re2); if (RREGEXP(re1)->len != RREGEXP(re2)->len) return Qfalse; - min = RREGEXP(re1)->len; - if (min > RREGEXP(re2)->len) min = RREGEXP(re2)->len; - if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, min) == 0 && + if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, RREGEXP(re1)->len) == 0 && rb_reg_cur_kcode(re1) == rb_reg_cur_kcode(re2) && RREGEXP(re1)->ptr->options == RREGEXP(re2)->ptr->options) { return Qtrue; |