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

sprintf.c: infect

* sprintf.c (ruby__sfvextra): the result should be infected by the
  given strings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-08-15 07:26:55 +00:00
parent bb545e2131
commit 665b06ec5b
3 changed files with 24 additions and 4 deletions

View file

@ -1,7 +1,4 @@
Wed Aug 15 16:23:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (ruby__sfvwrite): set buffer length and exclude
uninitialized garbage to get correct coderange.
Wed Aug 15 16:26:52 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (ruby__sfvextra): the result should be infected by the
given strings.

View file

@ -1210,6 +1210,7 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
StringValueCStr(value);
RSTRING_GETMEM(value, cp, *sz);
((rb_printf_buffer_extra *)fp)->value = value;
OBJ_INFECT(result, value);
return cp;
}

View file

@ -28,4 +28,26 @@ class Test_SPrintf < Test::Unit::TestCase
end
assert_equal("<\u{3042 3044 3046 3048 304a}>", Bug::Printf.s(self))
end
def test_taint
def self.to_s
super.taint
end
assert_equal({to_s: true, inspect: true},
{
to_s: Bug::Printf.s(self).tainted?,
inspect: Bug::Printf.v(self).tainted?,
})
end
def test_trust
def self.to_s
super.untrust
end
assert_equal({to_s: true, inspect: true},
{
to_s: Bug::Printf.s(self).untrusted?,
inspect: Bug::Printf.v(self).untrusted?,
})
end
end