* hash.c (env_reject_bang): untaint key string.

* hash.c (env_delete_m): execute block only if deleting key does
  not exist.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-03-31 02:06:23 +00:00
parent 5bfef93c44
commit d093279888
3 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,10 @@
Mon Mar 31 10:50:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (env_reject_bang): untaint key string.
* hash.c (env_delete_m): execute block only if deleting key does
not exist.
Sat Mar 29 17:54:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Sat Mar 29 17:54:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): do not call rb_str_buf_cat() with NULL ptr, * pack.c (pack_pack): do not call rb_str_buf_cat() with NULL ptr,

7
hash.c
View File

@ -1002,8 +1002,10 @@ static VALUE
env_delete_m(obj, name) env_delete_m(obj, name)
VALUE obj, name; VALUE obj, name;
{ {
VALUE val = env_delete(obj, name); VALUE val;
if (rb_block_given_p()) rb_yield(name);
val = env_delete(obj, name);
if (NIL_P(val) && rb_block_given_p()) rb_yield(name);
return val; return val;
} }
@ -1342,6 +1344,7 @@ env_reject_bang()
VALUE val = rb_f_getenv(Qnil, *ptr); VALUE val = rb_f_getenv(Qnil, *ptr);
if (!NIL_P(val)) { if (!NIL_P(val)) {
if (RTEST(rb_yield(rb_assoc_new(*ptr, val)))) { if (RTEST(rb_yield(rb_assoc_new(*ptr, val)))) {
FL_UNSET(*ptr, FL_TAINT);
env_delete(Qnil, *ptr); env_delete(Qnil, *ptr);
del++; del++;
} }

View File

@ -450,11 +450,11 @@ module Benchmark
STDOUT.sync = sync STDOUT.sync = sync
end end
def bm(label_width = 0, *labels, &blk) def bm(label_width = 0, *labels)
benchmark(" "*label_width + CAPTION, label_width, FMTSTR, *labels, &blk) benchmark(" "*label_width + CAPTION, label_width, FMTSTR, *labels){|*x|yield *x}
end end
def bmbm(width = 0, &blk) def bmbm(width = 0)
job = Job.new(width) job = Job.new(width)
yield(job) yield(job)
width = job.width width = job.width