What are the Ruby's Object#taint and Object#trust methods?

前端 未结 3 2088
有刺的猬
有刺的猬 2021-01-30 13:36

I was reading about Ruby string methods in the docs and came accross the methods

  • taint
  • trust
  • untaint
3条回答
  •  野性不改
    2021-01-30 13:41

    I found this link to me informative about tainted Data in ruby.

    http://ruby.about.com/od/advancedruby/a/tainted.htm

    "Tainted" objects are those that have come from some type of user input. Either from a file, the keyboard or the network, unless the object is a literal in the program or created by the program directly, it will be tainted. The tainted flag is always there on your objects, all you have to do is check it before you do anything unsafe. If you've confirmed that the data is indeed safe, you can then untaint the object.

提交回复
热议问题