Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6081

Show
Ignore:
Timestamp:
01/28/07 17:00:17 (2 years ago)
Author:
ulysses
Message:

Change the query parser to map empty GET params to "" rather than nil. Closes #5694.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6080 r6081  
    11*SVN* 
     2 
     3* Change the query parser to map empty GET params to "" rather than nil. Closes #5694. [Nicholas Seckar] 
    24 
    35* date_select and datetime_select take a :default option.  #7052 [nik.wakelin] 
  • trunk/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb

    r6044 r6081  
    1313        key, value = chunk.split('=', 2) 
    1414        next if key.empty? 
    15         value = (value.nil? || value.empty?) ? nil : CGI.unescape(value) 
     15        value = value.nil? ? nil : CGI.unescape(value) 
    1616        [ CGI.unescape(key), value ] 
    1717      end.compact 
  • trunk/actionpack/test/controller/cgi_test.rb

    r5904 r6081  
    99  def setup 
    1010    @query_string = "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1" 
    11     @query_string_with_nil = "action=create_customer&full_name=" 
     11    @query_string_with_empty = "action=create_customer&full_name=" 
    1212    @query_string_with_array = "action=create_customer&selected[]=1&selected[]=2&selected[]=3" 
    1313    @query_string_with_amps  = "action=create_customer&name=Don%27t+%26+Does" 
     
    6969  def test_query_string_with_nil 
    7070    assert_equal( 
    71       { "action" => "create_customer", "full_name" => nil}, 
    72       CGIMethods.parse_query_parameters(@query_string_with_nil
     71      { "action" => "create_customer", "full_name" => ''}, 
     72      CGIMethods.parse_query_parameters(@query_string_with_empty
    7373    ) 
    7474  end