diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-13 22:36:45 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-13 22:36:45 +0000 |
commit | 5b59142c474e2779e00de9cefd8970306d51bc6e (patch) | |
tree | f8c37585890c1b1fed97ce7e70294eeccdc1f0a4 | |
parent | bf1d10d07caba7df7d0d4f5e24bf106ffb96a91b (diff) | |
download | ruby-5b59142c474e2779e00de9cefd8970306d51bc6e.tar.gz ruby-5b59142c474e2779e00de9cefd8970306d51bc6e.tar.xz ruby-5b59142c474e2779e00de9cefd8970306d51bc6e.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@24914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/cgi/cookie.rb | 19 |
2 files changed, 18 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Mon Sep 14 06:42:21 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca> + + * 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@marc-andre.ca> * lib/net/http.rb (fetch): Handle properly default values; a patch by diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb index 68fbc8972..4588cd0f7 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 |