Created
August 25, 2008 16:14
-
-
Save joevandyk/7085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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