Revert r52872 "string.c: should not taint fstring"

This reverts commit b887c7c20ab81b50ed7cb8c7db3218c443985d6b.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2015-12-04 04:10:00 +00:00
parent 8068925a50
commit f2532ab8ca
3 changed files with 1 additions and 17 deletions

View File

@ -3,11 +3,6 @@ Fri Dec 4 11:22:40 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* thread.c (rb_thread_setname): name must be ascii-compatible, as * thread.c (rb_thread_setname): name must be ascii-compatible, as
pthread APIs do not accept legacy wide char strings. pthread APIs do not accept legacy wide char strings.
Thu Dec 3 16:02:17 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_obj_as_string): fstring should not be infected.
TODO: other frozen strings also may not be.
Thu Dec 3 15:39:21 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org> Thu Dec 3 15:39:21 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* lib/scanf.rb: fixed double words typo. * lib/scanf.rb: fixed double words typo.

View File

@ -1247,9 +1247,7 @@ rb_obj_as_string(VALUE obj)
str = rb_funcall(obj, idTo_s, 0); str = rb_funcall(obj, idTo_s, 0);
if (!RB_TYPE_P(str, T_STRING)) if (!RB_TYPE_P(str, T_STRING))
return rb_any_to_s(obj); return rb_any_to_s(obj);
if (!FL_SET(str, RSTRING_FSTR) && FL_ABLE(obj)) OBJ_INFECT(str, obj);
/* fstring must not be tainted, at least */
OBJ_INFECT_RAW(str, obj);
return str; return str;
} }

View File

@ -755,15 +755,6 @@ class TestObject < Test::Unit::TestCase
end end
EOS EOS
assert_match(/\bToS\u{3042}:/, x) assert_match(/\bToS\u{3042}:/, x)
name = "X".freeze
x = Object.new.taint
class<<x;self;end.class_eval {define_method(:to_s) {name}}
assert_same(name, x.to_s)
assert_not_predicate(name, :tainted?)
assert_raise(RuntimeError) {name.taint}
assert_equal("X", [x].join(""))
assert_not_predicate(name, :tainted?)
end end
def test_inspect def test_inspect