Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Skipping empty params inside query what lead to parsing error.

Example of these cookies would be: "foo=bar,;bar=foo" or ",foo=bar;,"
  • Loading branch information...
commit cb05a101cd7eae882cbd0ddd2b3a5c4597b08f28 1 parent 6496241
@josin josin authored
Showing with 3 additions and 0 deletions.
  1. +1 −0  lib/rack/utils.rb
  2. +2 −0  test/spec_utils.rb
1  lib/rack/utils.rb
@@ -67,6 +67,7 @@ def parse_query(qs, d = nil)
params =
(qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
+ next if p.empty?

I don't yet see the point of this change. If p is an empty string, then on the next line will result in an empty array, and we'll skip to the next iteration on the line after that. Is this just for code clarity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
k, v = p.split('=', 2).map { |x| unescape(x) }
next unless k || v
2  test/spec_utils.rb
@@ -118,6 +118,8 @@ def kcodeu
Rack::Utils.parse_query("&key&").should.equal "key" => nil
Rack::Utils.parse_query(";key;", ";,").should.equal "key" => nil
Rack::Utils.parse_query(",key,", ";,").should.equal "key" => nil
+ Rack::Utils.parse_query(";foo=bar,;", ";,").should.equal "foo" => "bar"
+ Rack::Utils.parse_query(",foo=bar;,", ";,").should.equal "foo" => "bar"
should "parse nested query strings correctly" do
Please sign in to comment.
Something went wrong with that request. Please try again.