AntiOffensiveString
Respond error for requests include some offensive string, that may crash browsers
Installation
Add this line to your application's Gemfile:
gem 'anti_offensive_string'
And then execute:
$ bundle
Or install it yourself as:
$ gem install anti_offensive_string
Usage
Rails
# config/application.rb
config.middleware.insert(0, AntiOffensiveString)
Other
# config.ru
use AntiOffensiveString
run ...
Customize error response
# respond with fixed value
AntiOffensiveString.error_response = [400, {'Content-Type' => "text/html"}, ['<h1>Error</h1>']]
# respond with block
AntiOffensiveString.on_offensive_request do |env|
p env # => rack env
[400, {'Content-Type' => "text/html"}, ['<h1>Error</h1>']]
end
See also: http://rack.rubyforge.org/doc/SPEC.html
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request