From: Arthur Schreiber Date: 2008-07-07T07:34:12+09:00 Subject: [ruby-core:17634] [Ruby 1.8 - Bug #229] (Open) CGI::Cookies can "get out of sync" Issue #229 has been reported by Arthur Schreiber. ---------------------------------------- Bug #229: CGI::Cookies can "get out of sync" http://redmine.ruby-lang.org/issues/show/229 Author: Arthur Schreiber Status: Open Priority: Normal Assigned to: Category: Target version: CGI::Cookies are an instance of a DelegateClass of their @value instance variable, which is always an Array. But changing a Cookie's value using the #value= instance method of CGI::Cookie causes the Cookie to "get out of sync": require "cgi" cookie = CGI::Cookie.new("my-cookie", "first value", "second value") cookie.value # => ["first value", "second value"] cookie[0] # => "first value" cookie[1] # => "second value" cookie[2] = "new value" cookie.each do |val| val # => "first value", "second value", "new value" end cookie.inspect # => "[\"first value\", \"second value\", \"new value\"]" cookie.to_s # => "my-cookie=first+value&second+value&new+value; path=" cookie = CGI::Cookie.new("my-cookie", "first value", "second value") cookie.value # => ["first value", "second value"] # This makes the cookie get out of sync cookie.value = [ "test" ] cookie[0] # => "first value" cookie[1] # => "second value" cookie[2] = "new value" cookie.each do |val| val # => "first value", "second value", "new value" end cookie.inspect # => "[\"first value\", \"second value\", \"new value\"]" cookie.to_s # => "my-cookie=test; path=" The attached patch fixes this issue. ---------------------------------------- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://redmine.ruby-lang.org/my/account