ruby-changes:13162
From: marcandre <ko1@a...>
Date: Mon, 14 Sep 2009 07:37:01 +0900 (JST)
Subject: [ruby-changes:13162] Ruby:r24914 (trunk): * lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the cookie itself. Based on a patch by Arthur Schreiber
marcandre 2009-09-14 07:36:45 +0900 (Mon, 14 Sep 2009) New Revision: 24914 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24914 Log: * lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the cookie itself. Based on a patch by Arthur Schreiber [ruby-core:17634] Modified files: trunk/ChangeLog trunk/lib/cgi/cookie.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24913) +++ ChangeLog (revision 24914) @@ -1,3 +1,8 @@ +Mon Sep 14 06:42:21 2009 Marc-Andre Lafortune <ruby-core@m...> + + * lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the + cookie itself. Based on a patch by Arthur Schreiber [ruby-core:17634] + Mon Sep 14 05:21:12 2009 Marc-Andre Lafortune <ruby-core@m...> * lib/net/http.rb (fetch): Handle properly default values; a patch by Index: lib/cgi/cookie.rb =================================================================== --- lib/cgi/cookie.rb (revision 24913) +++ lib/cgi/cookie.rb (revision 24914) @@ -55,11 +55,10 @@ def initialize(name = "", *value) if name.kind_of?(String) @name = name - @value = value %r|^(.*/)|.match(ENV["SCRIPT_NAME"]) @path = ($1 or "") @secure = false - return super(@value) + return super(value) end options = name @@ -68,7 +67,7 @@ end @name = options["name"] - @value = Array(options["value"]) + value = Array(options["value"]) # simple support for IE if options["path"] @path = options["path"] @@ -80,12 +79,20 @@ @expires = options["expires"] @secure = options["secure"] == true ? true : false - super(@value) + super(value) end - attr_accessor("name", "value", "path", "domain", "expires") + attr_accessor("name", "path", "domain", "expires") attr_reader("secure") + def value + self + end + + def value=(val) + replace(Array(val)) + end + # Set whether the Cookie is a secure cookie or not. # # +val+ must be a boolean. @@ -96,7 +103,7 @@ # Convert the Cookie to its string representation. def to_s - val = @value.kind_of?(String) ? CGI::escape(@value) : @value.collect{|v| CGI::escape(v) }.join("&") + val = collect{|v| CGI::escape(v) }.join("&") buf = "#{@name}=#{val}" buf << "; domain=#{@domain}" if @domain buf << "; path=#{@path}" if @path -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/