Prevent "ArgumentError: invalid %-encoding" for bad requests from spiders
This commit is contained in:
parent
6a3f51e250
commit
b5d2b49bd1
1
Gemfile
1
Gemfile
@ -32,6 +32,7 @@ gem 'newrelic_rpm'
|
||||
gem 'virtus', '~> 1.0.1'
|
||||
gem 'warden', '~> 1.2.3'
|
||||
gem 'pundit', '~> 0.2.3'
|
||||
gem 'rack-robustness', '~> 1.1.0'
|
||||
|
||||
group :development do
|
||||
gem 'quiet_assets', '~> 1.0.1'
|
||||
|
@ -219,6 +219,7 @@ GEM
|
||||
rack (1.5.2)
|
||||
rack-protection (1.5.0)
|
||||
rack
|
||||
rack-robustness (1.1.0)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (4.0.4)
|
||||
@ -382,6 +383,7 @@ DEPENDENCIES
|
||||
pry-rails (~> 0.3.2)
|
||||
pundit (~> 0.2.3)
|
||||
quiet_assets (~> 1.0.1)
|
||||
rack-robustness (~> 1.1.0)
|
||||
rails (= 4.0.4)
|
||||
rake (~> 10.0.4)
|
||||
rb-inotify (~> 0.9.0)
|
||||
|
@ -33,5 +33,13 @@ module Asciinema
|
||||
end
|
||||
|
||||
config.i18n.enforce_available_locales = true
|
||||
|
||||
config.middleware.use ::Rack::Robustness do |g|
|
||||
g.no_catch_all
|
||||
g.on(ArgumentError) { |ex| 400 }
|
||||
g.content_type 'text/plain'
|
||||
g.body{ |ex| ex.message }
|
||||
g.ensure(true) { |ex| env['rack.errors'].write(ex.message) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user