summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-14 14:22:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-14 14:22:11 +0000
commit6e918be6b182ac121412bdd53c78ec1b54b14593 (patch)
treeec2f7c5a884c4f259f7b4971e9ce5664952d35aa /lib
parent91c9ac216a7db83890e5e6ff7e90d50ce9fd1e35 (diff)
* gc.c, parse.y, lib/cgi.rb, lib/date.rb: last minute backports from HEAD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi.rb15
-rw-r--r--lib/cgi/session.rb6
-rw-r--r--lib/date.rb8
3 files changed, 18 insertions, 11 deletions
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 17bbdbeab9..3141d3d692 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -1125,17 +1125,16 @@ class CGI
@multipart
end
- class Value < DelegateClass(String) # :nodoc:
- def initialize(str, params)
+ module Value # :nodoc:
+ def set_params(params)
@params = params
- super(str)
end
def [](idx, *args)
if args.size == 0
warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
- self
+ @params[idx]
else
- self.to_s[idx,*args]
+ super[idx,*args]
end
end
def first
@@ -1165,7 +1164,10 @@ class CGI
Tempfile.new("CGI")
end
else
- Value.new(value || "", params)
+ str = if value then value.dup else "" end
+ str.extend(Value)
+ str.set_params(params)
+ str
end
end
@@ -2310,4 +2312,3 @@ class CGI
end
end # class CGI
-
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 8453501399..a44de7cb81 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -210,7 +210,7 @@ class CGI
#
# session_expires:: the time the current session expires, as a
# +Time+ object. If not set, the session will terminate
- # when the user's browser is closed.
+ # when the user's browser is closed.
# session_domain:: the hostname domain for which this session is valid.
# If not set, defaults to the hostname of the server.
# session_secure:: if +true+, this session will only work over HTTPS.
@@ -365,7 +365,6 @@ class CGI
raise ArgumentError, "session_id `%s' is invalid" % id
end
@path = dir+"/"+prefix+id
- @path.untaint
unless File::exist? @path
@hash = {}
end
@@ -413,7 +412,8 @@ class CGI
# Close and delete the session's FileStore file.
def delete
- File::unlink @path
+ File::unlink @path
+ rescue Errno::ENOENT
end
end
diff --git a/lib/date.rb b/lib/date.rb
index b50e987852..b8c15a420a 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -711,7 +711,13 @@ class Date
alias_method :__#{id.to_i}__, :#{id.to_s}
private :__#{id.to_i}__
def #{id.to_s}(*args, &block)
- (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]
+ if @__#{id.to_i}__
+ @__#{id.to_i}__
+ elsif ! self.frozen?
+ @__#{id.to_i}__ ||= __#{id.to_i}__(*args, &block)
+ else
+ __#{id.to_i}__(*args, &block)
+ end
end
end;
end