mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Disallow changing the origin of a cookie once it is set.
This commit is contained in:
parent
532101a102
commit
1a471513de
2 changed files with 5 additions and 0 deletions
|
|
@ -220,6 +220,8 @@ class HTTP::Cookie
|
|||
end
|
||||
|
||||
def origin=(origin)
|
||||
@origin.nil? or
|
||||
raise ArgumentError, "origin cannot be changed once it is set"
|
||||
origin = URI(origin)
|
||||
acceptable_from_uri?(origin) or
|
||||
raise ArgumentError, "unacceptable cookie sent from URI #{origin}"
|
||||
|
|
|
|||
|
|
@ -505,6 +505,9 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
assert_equal '/', cookie.path
|
||||
assert_equal 'example.com', cookie.domain
|
||||
assert_equal true, cookie.for_domain
|
||||
assert_raises(ArgumentError) {
|
||||
cookie.origin = URI.parse('http://www.example.com/')
|
||||
}
|
||||
|
||||
cookie_str = 'a=b; domain=example.com'
|
||||
cookie = HTTP::Cookie.parse(cookie_str).first
|
||||
|
|
|
|||
Loading…
Reference in a new issue