diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-01 15:48:39 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-01 15:48:39 +0000 |
commit | 73678acc9a277940a801aee58f9a9da918b14b44 (patch) | |
tree | 3f1464d292d42abdb1441d714263a2da00e177b1 /lib | |
parent | 00cd3b97e6f315e732ce45f9fba4a31f07a9bc32 (diff) |
merges r24914 from trunk into ruby_1_9_1.
--
* 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/branches/ruby_1_9_1@25621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cgi/cookie.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb index befe1402e6..0fc3b6427b 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 |