mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ec4e83ed56
commit
8053b7f3b1
4 changed files with 18 additions and 12 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Wed Jul 19 15:14:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* bignum.c (bigdivrem): should use rb_int2big(), not rb_uint2big().
|
||||||
|
|
||||||
Tue Jul 18 14:58:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
Tue Jul 18 14:58:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* eval.c (ruby_options): should treat SystemExit etc. properly.
|
* eval.c (ruby_options): should treat SystemExit etc. properly.
|
||||||
|
|
2
bignum.c
2
bignum.c
|
@ -804,7 +804,7 @@ bigdivrem(x, y, divp, modp)
|
||||||
}
|
}
|
||||||
RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
|
RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
|
||||||
if (!RBIGNUM(x)->sign) t2 = -(long)t2;
|
if (!RBIGNUM(x)->sign) t2 = -(long)t2;
|
||||||
if (modp) *modp = rb_uint2big(t2);
|
if (modp) *modp = rb_int2big((long)t2);
|
||||||
if (divp) *divp = z;
|
if (divp) *divp = z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
8
eval.c
8
eval.c
|
@ -92,9 +92,9 @@ static int scope_vmode;
|
||||||
int ruby_safe_level = 0;
|
int ruby_safe_level = 0;
|
||||||
/* safe-level:
|
/* safe-level:
|
||||||
0 - strings from streams/environment/ARGV are tainted (default)
|
0 - strings from streams/environment/ARGV are tainted (default)
|
||||||
1 - no dangerous operation by tainted string
|
1 - no dangerous operation by tainted value
|
||||||
2 - process/file operations prohibited
|
2 - process/file operations prohibited
|
||||||
3 - all genetated strings are tainted
|
3 - all genetated objects are tainted
|
||||||
4 - no global (non-tainted) variable modification/no direct output
|
4 - no global (non-tainted) variable modification/no direct output
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -5223,6 +5223,10 @@ rb_mod_modfunc(argc, argv, module)
|
||||||
ID id;
|
ID id;
|
||||||
NODE *body;
|
NODE *body;
|
||||||
|
|
||||||
|
if (TYPE(module) != T_MODULE) {
|
||||||
|
rb_raise(rb_eTypeError, "module_function must be called for modules");
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
SCOPE_SET(SCOPE_MODFUNC);
|
SCOPE_SET(SCOPE_MODFUNC);
|
||||||
return module;
|
return module;
|
||||||
|
|
|
@ -121,7 +121,7 @@ class CGI < SimpleDelegator
|
||||||
RFC822_MONTHS = %w[ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ]
|
RFC822_MONTHS = %w[ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ]
|
||||||
|
|
||||||
# make rfc1123 date string
|
# make rfc1123 date string
|
||||||
def rfc1123_date(time)
|
def CGI::rfc1123_date(time)
|
||||||
t = time.clone.gmtime
|
t = time.clone.gmtime
|
||||||
return format("%s, %.2d %s %d %.2d:%.2d:%.2d GMT",
|
return format("%s, %.2d %s %d %.2d:%.2d:%.2d GMT",
|
||||||
RFC822_DAYS[t.wday], t.day, RFC822_MONTHS[t.month-1], t.year,
|
RFC822_DAYS[t.wday], t.day, RFC822_MONTHS[t.month-1], t.year,
|
||||||
|
@ -129,22 +129,20 @@ class CGI < SimpleDelegator
|
||||||
end
|
end
|
||||||
|
|
||||||
# escape url encode
|
# escape url encode
|
||||||
def escape(str)
|
def CGI::escape(str)
|
||||||
str.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
|
str.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# unescape url encoded
|
# unescape url encoded
|
||||||
def unescape(str)
|
def CGI::unescape(str)
|
||||||
str.gsub(/\+/, ' ').gsub(/%([0-9a-fA-F]{2})/){ [$1.hex].pack("c") }
|
str.gsub(/\+/, ' ').gsub(/%([0-9a-fA-F]{2})/){ [$1.hex].pack("c") }
|
||||||
end
|
end
|
||||||
|
|
||||||
# escape HTML
|
# escape HTML
|
||||||
def escapeHTML(str)
|
def CGI::escapeHTML(str)
|
||||||
str.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
str.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
||||||
end
|
end
|
||||||
|
|
||||||
module_function :escape, :unescape, :escapeHTML, :rfc1123_date
|
|
||||||
|
|
||||||
# offline mode. read name=value pairs on standard input.
|
# offline mode. read name=value pairs on standard input.
|
||||||
def read_from_cmdline
|
def read_from_cmdline
|
||||||
require "shellwords.rb"
|
require "shellwords.rb"
|
||||||
|
@ -172,7 +170,7 @@ class CGI < SimpleDelegator
|
||||||
else
|
else
|
||||||
read_from_cmdline
|
read_from_cmdline
|
||||||
end.split(/[&;]/).each do |x|
|
end.split(/[&;]/).each do |x|
|
||||||
key, val = x.split(/=/,2).collect{|x|unescape(x)}
|
key, val = x.split(/=/,2).collect{|x|CGI::unescape(x)}
|
||||||
if @inputs.include?(key)
|
if @inputs.include?(key)
|
||||||
@inputs[key] += "\0" + (val or "")
|
@inputs[key] += "\0" + (val or "")
|
||||||
else
|
else
|
||||||
|
@ -185,8 +183,8 @@ class CGI < SimpleDelegator
|
||||||
if ENV.has_key?('HTTP_COOKIE') or ENV.has_key?('COOKIE')
|
if ENV.has_key?('HTTP_COOKIE') or ENV.has_key?('COOKIE')
|
||||||
(ENV['HTTP_COOKIE'] or ENV['COOKIE']).split("; ").each do |x|
|
(ENV['HTTP_COOKIE'] or ENV['COOKIE']).split("; ").each do |x|
|
||||||
key, val = x.split(/=/,2)
|
key, val = x.split(/=/,2)
|
||||||
key = unescape(key)
|
key = CGI::unescape(key)
|
||||||
val = val.split(/&/).collect{|x|unescape(x)}.join("\0")
|
val = val.split(/&/).collect{|x|CGI::unescape(x)}.join("\0")
|
||||||
if @cookie.include?(key)
|
if @cookie.include?(key)
|
||||||
@cookie[key] += "\0" + val
|
@cookie[key] += "\0" + val
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue