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

Changeset 5094

Show
Ignore:
Timestamp:
09/12/06 20:57:09 (2 years ago)
Author:
bitsweat
Message:

Skip params with empty names, such as the &=Save query string from <input type=submit/>. Closes #2569.

Files:

Legend:

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

    r5086 r5094  
    11*SVN* 
     2 
     3* Skip params with empty names, such as the &=Save query string from <input type="submit"/>.  #2569 [manfred, raphinou@yahoo.com] 
    24 
    35* Fix assert_tag so that :content => "foo" does not match substrings, but only exact strings. Use :content => /foo/ to match substrings. #2799 [Eric Hodel] 
  • trunk/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb

    r5070 r5094  
    1212        next if chunk.empty? 
    1313        key, value = chunk.split('=', 2) 
     14        next if key.empty? 
    1415        value = (value.nil? || value.empty?) ? nil : CGI.unescape(value) 
    1516        [ key, value ] 
     
    2728        finished = true 
    2829        for key, value in params 
    29           next unless key 
     30          next if key.blank? 
    3031          if !key.include?('[') 
    3132            # much faster to test for the most common case first (GET) 
  • trunk/actionpack/test/controller/cgi_test.rb

    r4866 r5094  
    1717    @query_string_without_equal = "action" 
    1818    @query_string_with_many_ampersands = 
    19       "&action=create_customer&&&full_name=David%20Heinemeier%20Hansson"     
     19      "&action=create_customer&&&full_name=David%20Heinemeier%20Hansson" 
     20    @query_string_with_empty_key = "action=create_customer&full_name=David%20Heinemeier%20Hansson&=Save" 
    2021  end 
    2122 
     
    99100      CGIMethods.parse_query_parameters(@query_string_without_equal) 
    100101    )     
     102  end 
     103   
     104  def test_query_string_with_empty_key 
     105    assert_equal( 
     106      { "action" => "create_customer", "full_name" => "David Heinemeier Hansson" }, 
     107      CGIMethods.parse_query_parameters(@query_string_with_empty_key) 
     108    ) 
    101109  end 
    102110 
     
    118126      "something_empty" => [ "" ], 
    119127      "products[first]" => [ "Apple Computer" ], 
    120       "products[second]" => [ "Pc" ] 
     128      "products[second]" => [ "Pc" ], 
     129      "" => [ 'Save' ] 
    121130    } 
    122131