Skip to content

Commit 1796021

Browse files
committed
* lib/webrick/httputils.rb(parse_query): align RFC1738.
[Bug ruby#8330][ruby-core:54601] * test/webrick/test_httputils.rb: add test for this update.
1 parent d0b7b41 commit 1796021

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/webrick/httputils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def parse_query(str)
371371
str.split(/[&;]/).each{|x|
372372
next if x.empty?
373373
key, val = x.split(/=/,2)
374-
key = unescape_form(key)
374+
key = unescape(key)
375375
val = unescape_form(val.to_s)
376376
val = FormData.new(val)
377377
val.name = key

test/webrick/test_httputils.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,17 @@ def test_escape_path
9393
assert_equal("/foo/bar/", escape_path("/foo/bar/"))
9494
assert_equal("/%25foo/bar/", escape_path("/%foo/bar/"))
9595
end
96+
97+
def test_parse_query
98+
assert_equal({"foo" => ""}, parse_query("foo"))
99+
assert_equal({"foo" => "bar"}, parse_query("foo=bar"))
100+
assert_equal({"foo" => "", "bar" => ""}, parse_query("foo&bar"))
101+
assert_equal({"foo" => "", "bar" => ""}, parse_query("foo;bar"))
102+
assert_equal({"foo" => "bar", "bar" => "baz"}, parse_query("foo=bar&bar=baz"))
103+
assert_equal({"foo" => "bar", "bar" => "baz"}, parse_query("foo=bar;bar=baz"))
104+
105+
bug8330 = '[ruby-core:54601]'
106+
assert_equal({"foo+bar" => ""}, parse_query("foo+bar"))
107+
assert_equal({"foo+bar" => "baz"}, parse_query("foo+bar=baz"))
108+
end
96109
end

0 commit comments

Comments
 (0)