class Rack::Cleanser

Constants

VERSION

Attributes

oversize_response[RW]

Public Class Methods

cleanse!(env) click to toggle source
# File lib/rack/cleanser.rb, line 45
def cleanse!(env)
  limit_param_length!(env)
  filter_bad_uri_encoding!(env)
end
clear!() click to toggle source
# File lib/rack/cleanser.rb, line 40
def clear!
  @want_uri_encoding_filtering = false
  @param_length_limits         = {}
end
filter_bad_uri_encoding() click to toggle source
# File lib/rack/cleanser.rb, line 22
def filter_bad_uri_encoding
  @want_uri_encoding_filtering = true
end
filter_bad_uri_encoding!(env) click to toggle source
# File lib/rack/cleanser.rb, line 30
def filter_bad_uri_encoding!(env)
  InvalidURIEncoding.new[env] if @want_uri_encoding_filtering
end
limit_param_length(name, options = {}, &block) click to toggle source
# File lib/rack/cleanser.rb, line 18
def limit_param_length(name, options = {}, &block)
  param_length_limits[name] = ParamLengthLimiter.new(name, options, block)
end
limit_param_length!(env) click to toggle source
# File lib/rack/cleanser.rb, line 34
def limit_param_length!(env)
  param_length_limits.each do |_name, limit|
    limit[env]
  end
end
new(app) click to toggle source
# File lib/rack/cleanser.rb, line 51
def initialize(app)
  @app = app
end
param_length_limits() click to toggle source
# File lib/rack/cleanser.rb, line 26
def param_length_limits
  @param_length_limits ||= {}
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/cleanser.rb, line 65
def call(env)
  cleanse!(env)
  @app.call(env)
rescue RequestTooLargeException => e
  self.class.oversize_response.call(env, e)
end