Class: ActionDispatch::Request::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/request/utils.rb

Overview

:nodoc:

Defined Under Namespace

Classes: NoNilParamEncoder, ParamEncoder

Class Method Summary collapse

Class Method Details

.check_param_encoding(params) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/action_dispatch/request/utils.rb', line 16

def self.check_param_encoding(params)
  case params
  when Array
    params.each { |element| check_param_encoding(element) }
  when Hash
    params.each_value { |value| check_param_encoding(value) }
  when String
    unless params.valid_encoding?
      # Raise Rack::Utils::InvalidParameterError for consistency with Rack.
      # ActionDispatch::Request#GET will re-raise as a BadRequest error.
      raise Rack::Utils::InvalidParameterError, "Non UTF-8 value: #{params}"
    end
  end
end

.normalize_encode_params(params) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/action_dispatch/request/utils.rb', line 8

def self.normalize_encode_params(params)
  if perform_deep_munge
    NoNilParamEncoder.normalize_encode_params params
  else
    ParamEncoder.normalize_encode_params params
  end
end