* 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
This commit is contained in:
parent
3fc0e0c181
commit
15e7e472e6
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Mon Jun 20 15:41:33 2011 Hiroshi Nakamura <nahi@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Sun Jun 19 13:31:26 2011 Shota Fukumori <sorah@tubusu.net>
|
Sun Jun 19 13:31:26 2011 Shota Fukumori <sorah@tubusu.net>
|
||||||
|
|
||||||
* NEWS: Introduce --hide-skip on test/unit.
|
* NEWS: Introduce --hide-skip on test/unit.
|
||||||
|
@ -57,7 +57,7 @@ module WEBrick
|
|||||||
ret = []
|
ret = []
|
||||||
cookie = nil
|
cookie = nil
|
||||||
ver = 0
|
ver = 0
|
||||||
str.split(/[;,]\s*/).each{|x|
|
str.split(/[;,]\s+/).each{|x|
|
||||||
key, val = x.split(/=/,2)
|
key, val = x.split(/=/,2)
|
||||||
val = val ? HTTPUtils::dequote(val) : ""
|
val = val ? HTTPUtils::dequote(val) : ""
|
||||||
case key
|
case key
|
||||||
|
@ -34,6 +34,7 @@ class TestWEBrickCookie < Test::Unit::TestCase
|
|||||||
data << 'Part_Number="Rocket_Launcher_0001"; $Path="/acme"; '
|
data << 'Part_Number="Rocket_Launcher_0001"; $Path="/acme"; '
|
||||||
data << 'Shipping="FedEx"; $Path="/acme"'
|
data << 'Shipping="FedEx"; $Path="/acme"'
|
||||||
cookies = WEBrick::Cookie.parse(data)
|
cookies = WEBrick::Cookie.parse(data)
|
||||||
|
assert_equal(3, cookies.size)
|
||||||
assert_equal(1, cookies[0].version)
|
assert_equal(1, cookies[0].version)
|
||||||
assert_equal("Customer", cookies[0].name)
|
assert_equal("Customer", cookies[0].name)
|
||||||
assert_equal("WILE_E_COYOTE", cookies[0].value)
|
assert_equal("WILE_E_COYOTE", cookies[0].value)
|
||||||
@ -54,24 +55,30 @@ class TestWEBrickCookie < Test::Unit::TestCase
|
|||||||
assert_equal("9865ecfd514be7f7", cookies[1].value)
|
assert_equal("9865ecfd514be7f7", cookies[1].value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parse_non_whitespace
|
def test_parse_no_whitespace
|
||||||
data = [
|
data = [
|
||||||
'$Version="1"; ',
|
'$Version="1"; ',
|
||||||
'Customer="WILE_E_COYOTE";$Path="/acme";',
|
'Customer="WILE_E_COYOTE";$Path="/acme";', # no SP between cookie-string
|
||||||
'Part_Number="Rocket_Launcher_0001";$Path="/acme";',
|
'Part_Number="Rocket_Launcher_0001";$Path="/acme";', # no SP between cookie-string
|
||||||
'Shipping="FedEx";$Path="/acme"'
|
'Shipping="FedEx";$Path="/acme"'
|
||||||
].join
|
].join
|
||||||
cookies = WEBrick::Cookie.parse(data)
|
cookies = WEBrick::Cookie.parse(data)
|
||||||
assert_equal(1, cookies[0].version)
|
assert_equal(1, cookies.size)
|
||||||
assert_equal("Customer", cookies[0].name)
|
end
|
||||||
assert_equal("WILE_E_COYOTE", cookies[0].value)
|
|
||||||
assert_equal("/acme", cookies[0].path)
|
def test_parse_too_much_whitespaces
|
||||||
assert_equal(1, cookies[1].version)
|
# According to RFC6265,
|
||||||
assert_equal("Part_Number", cookies[1].name)
|
# cookie-string = cookie-pair *( ";" SP cookie-pair )
|
||||||
assert_equal("Rocket_Launcher_0001", cookies[1].value)
|
# So single 0x20 is needed after ';'. We allow multiple spaces here for
|
||||||
assert_equal(1, cookies[2].version)
|
# compatibility with older WEBrick versions.
|
||||||
assert_equal("Shipping", cookies[2].name)
|
data = [
|
||||||
assert_equal("FedEx", cookies[2].value)
|
'$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
|
end
|
||||||
|
|
||||||
def test_parse_set_cookie
|
def test_parse_set_cookie
|
||||||
|
Loading…
x
Reference in New Issue
Block a user