From 5904f64dbf9b8d78c8431e6ac19663624cbe599e Mon Sep 17 00:00:00 2001 From: marcandre Date: Sun, 13 Sep 2009 22:36:45 +0000 Subject: * 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/cgi/cookie.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/cgi/cookie.rb') diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb index 68fbc8972c..4588cd0f7a 100644 --- a/lib/cgi/cookie.rb +++ b/lib/cgi/cookie.rb @@ -55,11 +55,10 @@ class CGI 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 @@ class CGI 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 @@ class CGI @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 @@ class CGI # 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 -- cgit v1.2.3