lib/rack/query_parser.rb in rack-2.2.3.1 vs lib/rack/query_parser.rb in rack-2.2.4

- old
+ new

@@ -14,10 +14,14 @@ # InvalidParameterError is the error that is raised when incoming structural # parameters (parsed by parse_nested_query) contain invalid format or byte # sequence. class InvalidParameterError < ArgumentError; end + # ParamsTooDeepError is the error that is raised when params are recursively + # nested over the specified limit. + class ParamsTooDeepError < RangeError; end + def self.make_default(key_space_limit, param_depth_limit) new Params, key_space_limit, param_depth_limit end attr_reader :key_space_limit, :param_depth_limit @@ -79,11 +83,11 @@ # normalize_params recursively expands parameters into structural types. If # the structural types represented by two different parameter names are in # conflict, a ParameterTypeError is raised. def normalize_params(params, name, v, depth) - raise RangeError if depth <= 0 + raise ParamsTooDeepError if depth <= 0 name =~ %r(\A[\[\]]*([^\[\]]+)\]*) k = $1 || '' after = $' || '' @@ -166,10 +170,10 @@ @params[key] end def []=(key, value) @size += key.size if key && !@params.key?(key) - raise RangeError, 'exceeded available parameter key space' if @size > @limit + raise ParamsTooDeepError, 'exceeded available parameter key space' if @size > @limit @params[key] = value end def key?(key) @params.key?(key)