summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--configure.in3
-rw-r--r--io.c3
-rw-r--r--lib/cgi/session.rb17
-rw-r--r--lib/cgi/session/pstore.rb5
-rw-r--r--rubyio.h4
-rw-r--r--string.c6
7 files changed, 41 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 52745d6678..a5dfb65ea5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,11 @@ Sat Nov 20 01:45:04 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* test/xmlrpc/test_webrick_server.rb : move `requrie "webrick/https"'
into #setup_http_server mohtod to avoid soap test errors.
+Sat Nov 20 00:07:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (str_gsub): internal buffer should not be listed by
+ ObjectSpace.each_object() by String#gsub. [ruby-dev:24931]
+
Fri Nov 19 22:44:43 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/test/unit/collector/dir.rb: better support for -p/-x option.
@@ -63,6 +68,12 @@ Fri Nov 19 10:32:36 2004 Shugo Maeda <shugo@ruby-lang.org>
* ext/readline/readline.c (readline_s_set_completion_append_character):
accept nil. [ruby-core:03765]
+Fri Nov 19 01:20:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise
+ exception if data corresponding to session specified from the
+ client does not exist.
+
Fri Nov 19 00:59:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): internal buffer should not be listed by
diff --git a/configure.in b/configure.in
index 30444e6765..cff1e174e0 100644
--- a/configure.in
+++ b/configure.in
@@ -588,6 +588,9 @@ else
AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
fi
+AC_CHECK_HEADERS(stdio_ext.h)
+AC_CHECK_FUNCS(__fpending)
+
AC_MSG_CHECKING(read count field in FILE structures)
AC_CACHE_VAL(rb_cv_fcnt,
[for fcnt in dnl
diff --git a/io.c b/io.c
index 2b459ca1aa..e081477772 100644
--- a/io.c
+++ b/io.c
@@ -127,6 +127,9 @@ static VALUE lineno = INT2FIX(0);
# define READ_DATA_PENDING_COUNT(fp) ((fp)->_egptr - (fp)->_gptr)
# define READ_DATA_PENDING_PTR(fp) ((fp)->_gptr)
# endif
+#elif defined(HAVE___FPENDING)
+# define READ_DATA_PENDING(fp) (__fpending(fp) > 0)
+# define READ_DATA_PENDING_COUNT(fp) (__fpending(fp))
#elif defined(FILE_COUNT)
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_COUNT)
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 401ce089c0..5d9e767356 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -156,7 +156,7 @@ class CGI
class Session
# The id of this session.
- attr_reader :session_id
+ attr_reader :session_id, :new_session
def Session::callback(dbman) #:nodoc:
Proc.new{
@@ -170,7 +170,7 @@ class CGI
# a random number, and a constant string. This routine
# is used internally for automatically generated
# session ids.
- def Session::create_new_id
+ def create_new_id
require 'digest/md5'
md5 = Digest::MD5::new
now = Time::now
@@ -179,8 +179,10 @@ class CGI
md5.update(String(rand(0)))
md5.update(String($$))
md5.update('foobar')
+ @new_session = true
md5.hexdigest[0,16]
end
+ private :create_new_id
# Create a new CGI::Session object for +request+.
#
@@ -239,6 +241,7 @@ class CGI
# end
#
def initialize(request, option={})
+ @new_session = false
session_key = option['session_key'] || '_session_id'
id = option['session_id']
unless id
@@ -367,6 +370,9 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
@path = dir+"/"+prefix+md5+suffix
unless File::exist? @path
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
@hash = {}
end
end
@@ -433,7 +439,12 @@ class CGI
# currently recognised.
def initialize(session, option=nil)
@session_id = session.session_id
- GLOBAL_HASH_TABLE[@session_id] ||= {}
+ unless GLOBAL_HASH_TABLE.key?(@session_id)
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
+ GLOBAL_HASH_TABLE[@session_id] = {}
+ end
end
# Restore session state.
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
index e2727b5c5e..40d2214c20 100644
--- a/lib/cgi/session/pstore.rb
+++ b/lib/cgi/session/pstore.rb
@@ -61,7 +61,10 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
path = dir+"/"+prefix+md5
path.untaint
- unless File::exist? path
+ unless File::exist?(path)
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
@hash = {}
end
@p = ::PStore.new(path)
diff --git a/rubyio.h b/rubyio.h
index 3ae67b2762..200232939f 100644
--- a/rubyio.h
+++ b/rubyio.h
@@ -16,6 +16,10 @@
#include <stdio.h>
#include <errno.h>
+#if defined(HAVE_STDIO_EXT_H)
+#include <stdio_ext.h>
+#endif
+
typedef struct OpenFile {
FILE *f; /* stdio ptr for read/write */
FILE *f2; /* additional ptr for rw pipes */
diff --git a/string.c b/string.c
index efa817ea43..454959abc0 100644
--- a/string.c
+++ b/string.c
@@ -2075,10 +2075,7 @@ str_gsub(argc, argv, str, bang)
}
blen = RSTRING(str)->len + 30; /* len + margin */
- dest = rb_str_new5(str, 0, blen);
- if (bang) {
- RBASIC(dest)->klass = 0;
- }
+ dest = str_new(0, 0, blen);
buf = RSTRING(dest)->ptr;
bp = buf;
sp = cp = RSTRING(str)->ptr;
@@ -2158,6 +2155,7 @@ str_gsub(argc, argv, str, bang)
RSTRING(dest)->len = 0;
}
else {
+ RBASIC(dest)->klass = rb_obj_class(str);
OBJ_INFECT(dest, str);
str = dest;
}