1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Sanitizing and Untainting


If you can verify that the string from user input is safe, or can remove the offending parts, you can untaint the object. The following method will remove any characters other than lowercase letters, untaint the string and return it. It can then be safely passed to the safe_resize method without fear of mischief.

 def sanitize_input(string)
   safe_string = string.gsub(/[^a-z]/, '')
   return safe_string
  1. About.com
  2. Technology
  3. Ruby
  4. Advanced Ruby
  5. Sanitizing and Untainting

©2014 About.com. All rights reserved.