Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created August 25, 2008 16:14
Show Gist options
  • Save joevandyk/7085 to your computer and use it in GitHub Desktop.
Save joevandyk/7085 to your computer and use it in GitHub Desktop.
# Install WhiteList plugin from http://svn.techno-weenie.net/projects/plugins/white_list/
class ApplicationController < ActionController::Base
before_filter :strip_naughty_stuff_from_forms
private
def strip_naughty_stuff_from_forms
strip_naughty_stuff_from_hash(params)
end
def strip_naughty_stuff_from_hash hsh
return unless hsh.respond_to?(:each_pair)
hsh.each_pair do |key, value|
if value.class == String
hsh[key] = white_list(value)
elsif value.respond_to?(:[])
strip_naughty_stuff_from_hash(value)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment