diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-06-09 15:59:08 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-06-09 15:59:08 -0700 |
commit | ead65bb68702a1b9f235ff79320a04f6b008dd1b (patch) | |
tree | 519716660362421c6c792e48eca74d6553d6292f /lib/rack/query_parser.rb | |
parent | d4b4d14d40fe33f55e2d530db049d390832dcf0a (diff) | |
download | rack-ead65bb68702a1b9f235ff79320a04f6b008dd1b.tar.gz |
consolidate where to find the default_query_parser make keyspace required
we should only be able to find the default_query_parser in one place,
Utils. Also the keyspace size should be a require parameter
Diffstat (limited to 'lib/rack/query_parser.rb')
-rw-r--r-- | lib/rack/query_parser.rb | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/rack/query_parser.rb b/lib/rack/query_parser.rb index ca73f001..118bd704 100644 --- a/lib/rack/query_parser.rb +++ b/lib/rack/query_parser.rb @@ -12,10 +12,15 @@ module Rack # sequence. class InvalidParameterError < ArgumentError; end - attr_reader :params_class + def self.make_default(key_space_limit) + new Params, key_space_limit + end + + attr_reader :params_class, :key_space_limit - def initialize(params_class) + def initialize(params_class, key_space_limit) @params_class = params_class + @key_space_limit = key_space_limit end # Stolen from Mongrel, with some small modifications: @@ -103,7 +108,11 @@ module Rack end def make_params - @params_class.new + @params_class.new @key_space_limit + end + + def new(key_space_limit) + self.class.new @params_class, key_space_limit end private @@ -117,14 +126,8 @@ module Rack end class Params - class << self - # The default number of bytes to allow parameter keys to take up. - # This helps prevent a rogue client from flooding a Request. - attr_accessor :limit - end - - def initialize(limit = self.class.limit) - @limit = limit || 65536 + def initialize(limit) + @limit = limit @size = 0 @params = {} end @@ -160,7 +163,5 @@ module Rack hash end end - - DEFAULT = new(Params) end end |