summaryrefslogtreecommitdiff
path: root/test/webrick
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-20 06:48:40 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-20 06:48:40 +0000
commit15e7e472e65fd6110a42674f9e4ef73fd1f8bbdc (patch)
treeec060b38e5180bb4f460817bb71adadc494d1b00 /test/webrick
parent3fc0e0c18155adc610761d419576c3bae3150f13 (diff)
* lib/webrick/cookie.rb (WEBrick::Cookie.parse): Revert r31228.
r31228 was for allowing the 'Cookie:' header which did not have no SP after ';' for separating cookie-pairs but RFC6265 requires single SP after ';' there. We allow multiple SPs here for compatibility with older WEBrick version. * test/webrick/test_cookie.rb: Test it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick')
-rw-r--r--test/webrick/test_cookie.rb35
1 files changed, 21 insertions, 14 deletions
diff --git a/test/webrick/test_cookie.rb b/test/webrick/test_cookie.rb
index 48f0235..1652f39 100644
--- a/test/webrick/test_cookie.rb
+++ b/test/webrick/test_cookie.rb
@@ -34,6 +34,7 @@ class TestWEBrickCookie < Test::Unit::TestCase
data << 'Part_Number="Rocket_Launcher_0001"; $Path="/acme"; '
data << 'Shipping="FedEx"; $Path="/acme"'
cookies = WEBrick::Cookie.parse(data)
+ assert_equal(3, cookies.size)
assert_equal(1, cookies[0].version)
assert_equal("Customer", cookies[0].name)
assert_equal("WILE_E_COYOTE", cookies[0].value)
@@ -54,24 +55,30 @@ class TestWEBrickCookie < Test::Unit::TestCase
assert_equal("9865ecfd514be7f7", cookies[1].value)
end
- def test_parse_non_whitespace
+ def test_parse_no_whitespace
data = [
- '$Version="1";',
- 'Customer="WILE_E_COYOTE";$Path="/acme";',
- 'Part_Number="Rocket_Launcher_0001";$Path="/acme";',
+ '$Version="1"; ',
+ 'Customer="WILE_E_COYOTE";$Path="/acme";', # no SP between cookie-string
+ 'Part_Number="Rocket_Launcher_0001";$Path="/acme";', # no SP between cookie-string
'Shipping="FedEx";$Path="/acme"'
].join
cookies = WEBrick::Cookie.parse(data)
- assert_equal(1, cookies[0].version)
- assert_equal("Customer", cookies[0].name)
- assert_equal("WILE_E_COYOTE", cookies[0].value)
- assert_equal("/acme", cookies[0].path)
- assert_equal(1, cookies[1].version)
- assert_equal("Part_Number", cookies[1].name)
- assert_equal("Rocket_Launcher_0001", cookies[1].value)
- assert_equal(1, cookies[2].version)
- assert_equal("Shipping", cookies[2].name)
- assert_equal("FedEx", cookies[2].value)
+ assert_equal(1, cookies.size)
+ end
+
+ def test_parse_too_much_whitespaces
+ # According to RFC6265,
+ # cookie-string = cookie-pair *( ";" SP cookie-pair )
+ # So single 0x20 is needed after ';'. We allow multiple spaces here for
+ # compatibility with older WEBrick versions.
+ data = [
+ '$Version="1"; ',
+ 'Customer="WILE_E_COYOTE";$Path="/acme"; ', # no SP between cookie-string
+ 'Part_Number="Rocket_Launcher_0001";$Path="/acme"; ', # no SP between cookie-string
+ 'Shipping="FedEx";$Path="/acme"'
+ ].join
+ cookies = WEBrick::Cookie.parse(data)
+ assert_equal(3, cookies.size)
end
def test_parse_set_cookie