What are tainted objects, and when should we untaint them?
问题 When do Ruby objects need to be made tainted and when should we untaint them? How does the concept of tainted object make a Ruby script run in safe mode? Can anyone elaborate on this to make the concept clear with some code snippets? 回答1: What is Tainted? User input is tainted, by definition. For example: string = gets string.tainted? # => true You can also manually taint an object. string = 'Not yet tainted.' string.tainted? # => false (string = 'Explicitly taint me!').taint string.tainted?