mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
A cookie value may be DQUOTE'd as per RFC 6265 2.2.
Escaping with the backslash character is not mentioned in the RFC but the backslash character is not allowed here anyway, so just be nice and support it for legacy applications.
This commit is contained in:
parent
6c5e87aff3
commit
7d81c10914
2 changed files with 7 additions and 1 deletions
|
|
@ -190,6 +190,12 @@ class HTTP::Cookie
|
|||
first_elem, *cookie_elem = c.split(/;+/)
|
||||
first_elem.strip!
|
||||
key, value = first_elem.split(/\=/, 2)
|
||||
# RFC 6265 2.2
|
||||
# A cookie-value may be DQUOTE'd.
|
||||
case value
|
||||
when /\A"(.*)"\z/
|
||||
value = $1.gsub(/\\(.)/, "\\1")
|
||||
end
|
||||
|
||||
begin
|
||||
cookie = new(key, value.dup)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
|
||||
assert_equal 1, HTTP::Cookie.parse(cookie_str, :origin => uri) { |cookie|
|
||||
assert_equal 'quoted', cookie.name
|
||||
assert_equal '"value"', cookie.value
|
||||
assert_equal 'value', cookie.value
|
||||
assert_equal 'comment is "comment"', cookie.comment
|
||||
}.size
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue