No commit activity in last 3 years
No release in over 3 years
Respond error for requests include some offensive string, that may crash browsers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.0.6
>= 0

Runtime

>= 0
 Project Readme

AntiOffensiveString

Respond error for requests include some offensive string, that may crash browsers

http://techcrunch.com/2013/08/29/bug-in-apples-coretext-allows-specific-string-of-characters-to-crash-ios-6-os-x-10-8-apps/

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request