mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Simplify CgiRequest#query_parameters
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6743 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -23,8 +23,9 @@ module ActionController
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# DEPRECATED: Use parse_form_encoded_parameters
|
||||
def parse_query_parameters(query_string)
|
||||
return {} if query_string.blank?
|
||||
|
||||
pairs = query_string.split('&').collect do |chunk|
|
||||
next if chunk.empty?
|
||||
key, value = chunk.split('=', 2)
|
||||
@@ -33,12 +34,11 @@ module ActionController
|
||||
[ CGI.unescape(key), value ]
|
||||
end.compact
|
||||
|
||||
FormEncodedPairParser.new(pairs).result
|
||||
UrlEncodedPairParser.new(pairs).result
|
||||
end
|
||||
|
||||
# DEPRECATED: Use parse_form_encoded_parameters
|
||||
def parse_request_parameters(params)
|
||||
parser = FormEncodedPairParser.new
|
||||
parser = UrlEncodedPairParser.new
|
||||
|
||||
params = params.dup
|
||||
until params.empty?
|
||||
@@ -112,7 +112,7 @@ module ActionController
|
||||
end
|
||||
end
|
||||
|
||||
class FormEncodedPairParser < StringScanner #:nodoc:
|
||||
class UrlEncodedPairParser < StringScanner #:nodoc:
|
||||
attr_reader :top, :parent, :result
|
||||
|
||||
def initialize(pairs = [])
|
||||
|
||||
@@ -69,8 +69,7 @@ module ActionController #:nodoc:
|
||||
end
|
||||
|
||||
def query_parameters
|
||||
@query_parameters ||=
|
||||
(qs = self.query_string).empty? ? {} : CGI.parse_query_parameters(qs)
|
||||
@query_parameters ||= CGI.parse_query_parameters(query_string)
|
||||
end
|
||||
|
||||
def request_parameters
|
||||
|
||||
Reference in New Issue
Block a user