Skip to content

Commit

Permalink
Change the query parser to map empty GET params to "" rather than nil.
Browse files Browse the repository at this point in the history
…Closes #5694.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6081 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
seckar committed Jan 28, 2007
1 parent d6d94c7 commit 17a9405
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Change the query parser to map empty GET params to "" rather than nil. Closes #5694. [Nicholas Seckar]

* date_select and datetime_select take a :default option. #7052 [nik.wakelin]
date_select "post", "written_on", :default => 3.days.from_now
date_select "credit_card", "bill_due", :default => { :day => 20 }
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
Expand Up @@ -12,7 +12,7 @@ def parse_query_parameters(query_string)
next if chunk.empty?
key, value = chunk.split('=', 2)
next if key.empty?
value = (value.nil? || value.empty?) ? nil : CGI.unescape(value)
value = value.nil? ? nil : CGI.unescape(value)
[ CGI.unescape(key), value ]
end.compact

Expand Down
6 changes: 3 additions & 3 deletions actionpack/test/controller/cgi_test.rb
Expand Up @@ -8,7 +8,7 @@
class CGITest < Test::Unit::TestCase
def setup
@query_string = "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1"
@query_string_with_nil = "action=create_customer&full_name="
@query_string_with_empty = "action=create_customer&full_name="
@query_string_with_array = "action=create_customer&selected[]=1&selected[]=2&selected[]=3"
@query_string_with_amps = "action=create_customer&name=Don%27t+%26+Does"
@query_string_with_multiple_of_same_name =
Expand Down Expand Up @@ -68,8 +68,8 @@ def test_deep_query_string_with_array_of_hashes_with_multiple_pairs

def test_query_string_with_nil
assert_equal(
{ "action" => "create_customer", "full_name" => nil},
CGIMethods.parse_query_parameters(@query_string_with_nil)
{ "action" => "create_customer", "full_name" => ''},
CGIMethods.parse_query_parameters(@query_string_with_empty)
)
end

Expand Down

0 comments on commit 17a9405

Please sign in to comment.