Permalink
Browse files

* lib/webrick/httputils.rb(parse_query): align RFC1738.

  [Bug #8330][ruby-core:54601]
* test/webrick/test_httputils.rb: add test for this update.
  • Loading branch information...
1 parent d0b7b41 commit 179602196f25d1fd7350cfd88a44f0a5c49be3aa @ayumin committed May 3, 2013
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/webrick/httputils.rb
  2. +13 −0 test/webrick/test_httputils.rb
View
@@ -371,7 +371,7 @@ def parse_query(str)
str.split(/[&;]/).each{|x|
next if x.empty?
key, val = x.split(/=/,2)
- key = unescape_form(key)
+ key = unescape(key)
val = unescape_form(val.to_s)
val = FormData.new(val)
val.name = key
@@ -93,4 +93,17 @@ def test_escape_path
assert_equal("/foo/bar/", escape_path("/foo/bar/"))
assert_equal("/%25foo/bar/", escape_path("/%foo/bar/"))
end
+
+ def test_parse_query
+ assert_equal({"foo" => ""}, parse_query("foo"))
+ assert_equal({"foo" => "bar"}, parse_query("foo=bar"))
+ assert_equal({"foo" => "", "bar" => ""}, parse_query("foo&bar"))
+ assert_equal({"foo" => "", "bar" => ""}, parse_query("foo;bar"))
+ assert_equal({"foo" => "bar", "bar" => "baz"}, parse_query("foo=bar&bar=baz"))
+ assert_equal({"foo" => "bar", "bar" => "baz"}, parse_query("foo=bar;bar=baz"))
+
+ bug8330 = '[ruby-core:54601]'
+ assert_equal({"foo+bar" => ""}, parse_query("foo+bar"))
+ assert_equal({"foo+bar" => "baz"}, parse_query("foo+bar=baz"))
+ end
end

0 comments on commit 1796021

Please sign in to comment.