1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
wakou 2000-12-14 00:26:05 +00:00
parent 3e865dceff
commit 652f744cba
3 changed files with 74 additions and 53 deletions

View file

@ -1,3 +1,11 @@
Thu Dec 14 09:20:26 2000 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/cgi.rb: support -T1 on ruby 1.6.2
* lib/cgi.rb: $1 --> Regexp::last_match[1]
* lib/net/telnet.rb: ditto.
Wed Dec 13 12:41:27 2000 WATANABE Hirofumi <eban@ruby-lang.org> Wed Dec 13 12:41:27 2000 WATANABE Hirofumi <eban@ruby-lang.org>
* ruby.c (proc_options): accept "--^M" for DOS line endings. * ruby.c (proc_options): accept "--^M" for DOS line endings.

View file

@ -4,7 +4,7 @@
cgi.rb - cgi support library cgi.rb - cgi support library
Version 2.1.0 Version 2.1.1
Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
@ -185,10 +185,10 @@ class CGI
CR = "\015" CR = "\015"
LF = "\012" LF = "\012"
EOL = CR + LF EOL = CR + LF
VERSION = "2.1.0" VERSION = "2.1.1"
RELEASE_DATE = "2000-10-12" RELEASE_DATE = "2000-12-14"
VERSION_CODE = 210 VERSION_CODE = 211
RELEASE_CODE = 20001012 RELEASE_CODE = 20001214
NEEDS_BINMODE = true if /WIN/ni === RUBY_PLATFORM NEEDS_BINMODE = true if /WIN/ni === RUBY_PLATFORM
PATH_SEPARATOR = {'UNIX'=>'/', 'WINDOWS'=>'\\', 'MACINTOSH'=>':'} PATH_SEPARATOR = {'UNIX'=>'/', 'WINDOWS'=>'\\', 'MACINTOSH'=>':'}
@ -241,7 +241,7 @@ class CGI
=end =end
def CGI::escape(string) def CGI::escape(string)
string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase '%' + Regexp::last_match[1].unpack('H2' * Regexp::last_match[1].size).join('%').upcase
end.tr(' ', '+') end.tr(' ', '+')
end end
@ -252,7 +252,7 @@ class CGI
=end =end
def CGI::unescape(string) def CGI::unescape(string)
string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do
[$1.delete('%')].pack('H*') [Regexp::last_match[1].delete('%')].pack('H*')
end end
end end
@ -272,34 +272,34 @@ class CGI
=end =end
def CGI::unescapeHTML(string) def CGI::unescapeHTML(string)
string.gsub(/&(.*?);/n) do string.gsub(/&(.*?);/n) do
match = $1.dup match = Regexp::last_match[1].dup
case match case match
when /\Aamp\z/ni then '&' when /\Aamp\z/ni then '&'
when /\Aquot\z/ni then '"' when /\Aquot\z/ni then '"'
when /\Agt\z/ni then '>' when /\Agt\z/ni then '>'
when /\Alt\z/ni then '<' when /\Alt\z/ni then '<'
when /\A#(\d+)\z/n then when /\A#(\d+)\z/n then
if Integer($1) < 256 if Integer(Regexp::last_match[1]) < 256
Integer($1).chr Integer(Regexp::last_match[1]).chr
else else
if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U) if Integer(Regexp::last_match[1]) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
[Integer($1)].pack("U") [Integer(Regexp::last_match[1])].pack("U")
else else
"&##{$1};" "&##{Regexp::last_match[1]};"
end end
end end
when /\A#x([0-9a-f]+)\z/ni then when /\A#x([0-9a-f]+)\z/ni then
if $1.hex < 256 if Regexp::last_match[1].hex < 256
$1.hex.chr Regexp::last_match[1].hex.chr
else else
if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U) if Regexp::last_match[1].hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
[$1.hex].pack("U") [Regexp::last_match[1].hex].pack("U")
else else
"&#x#{$1};" "&#x#{Regexp::last_match[1]};"
end end
end end
else else
"&#{$1};" "&#{Regexp::last_match[1]};"
end end
end end
end end
@ -316,7 +316,7 @@ class CGI
def CGI::escapeElement(string, *element) def CGI::escapeElement(string, *element)
unless element.empty? unless element.empty?
string.gsub(/<\/?(?:#{element.join("|")})(?!\w)(?:.|\n)*?>/ni) do string.gsub(/<\/?(?:#{element.join("|")})(?!\w)(?:.|\n)*?>/ni) do
CGI::escapeHTML($&) CGI::escapeHTML(Regexp::last_match[0])
end end
else else
string string
@ -336,7 +336,7 @@ class CGI
=end =end
def CGI::unescapeElement(string, *element) def CGI::unescapeElement(string, *element)
string.gsub(/&lt;\/?(?:#{element.join("|")})(?!\w)(?:.|\n)*?&gt;/ni) do string.gsub(/&lt;\/?(?:#{element.join("|")})(?!\w)(?:.|\n)*?&gt;/ni) do
CGI::unescapeHTML($&) CGI::unescapeHTML(Regexp::last_match[0])
end end
end end
@ -491,7 +491,7 @@ status:
if defined?(MOD_RUBY) if defined?(MOD_RUBY)
buf.scan(/([^:]+): (.+)#{EOL}/n){ buf.scan(/([^:]+): (.+)#{EOL}/n){
Apache::request[$1] = $2 Apache::request[Regexp::last_match[1]] = Regexp::last_match[2]
} }
Apache::request.send_http_header Apache::request.send_http_header
'' ''
@ -787,7 +787,7 @@ convert string charset, and set language to "ja".
if (not head) and (/#{EOL}#{EOL}/n === buf) if (not head) and (/#{EOL}#{EOL}/n === buf)
buf = buf.sub(/\A((?:.|\n)*?#{EOL})#{EOL}/n) do buf = buf.sub(/\A((?:.|\n)*?#{EOL})#{EOL}/n) do
head = $1.dup head = Regexp::last_match[1].dup
"" ""
end end
next next
@ -809,8 +809,8 @@ convert string charset, and set language to "ja".
end end
buf = buf.sub(/\A((?:.|\n)*?)(?:#{EOL})?#{boundary}(#{EOL}|--)/n) do buf = buf.sub(/\A((?:.|\n)*?)(?:#{EOL})?#{boundary}(#{EOL}|--)/n) do
body.print $1 body.print Regexp::last_match[1]
if "--" == $2 if "--" == Regexp::last_match[2]
content_length = -1 content_length = -1
end end
"" ""
@ -828,27 +828,27 @@ convert string charset, and set language to "ja".
eval <<-END eval <<-END
def body.original_filename def body.original_filename
#{ #{
filename = ($1 or "").dup filename = (Regexp::last_match[1] or "").dup
if (/Mac/ni === env_table['HTTP_USER_AGENT']) and if (/Mac/ni === env_table['HTTP_USER_AGENT']) and
(/Mozilla/ni === env_table['HTTP_USER_AGENT']) and (/Mozilla/ni === env_table['HTTP_USER_AGENT']) and
(not /MSIE/ni === env_table['HTTP_USER_AGENT']) (not /MSIE/ni === env_table['HTTP_USER_AGENT'])
CGI::unescape(filename) CGI::unescape(filename)
else else
filename filename
end.dump end.dump.untaint
} }.taint
end end
END END
/Content-Type: (.*)/ni === head /Content-Type: (.*)/ni === head
eval <<-END eval <<-END
def body.content_type def body.content_type
#{($1 or "").dump} #{(Regexp::last_match[1] or "").dump.untaint}.taint
end end
END END
/Content-Disposition:.* name="?([^\";]*)"?/ni === head /Content-Disposition:.* name="?([^\";]*)"?/ni === head
name = $1.dup name = Regexp::last_match[1].dup
if params.has_key?(name) if params.has_key?(name)
params[name].push(body) params[name].push(body)
@ -891,7 +891,7 @@ convert string charset, and set language to "ja".
if ("POST" == env_table['REQUEST_METHOD']) and if ("POST" == env_table['REQUEST_METHOD']) and
(%r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n === (%r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n ===
env_table['CONTENT_TYPE']) env_table['CONTENT_TYPE'])
boundary = $1.dup boundary = Regexp::last_match[1].dup
@params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH'])) @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
else else
@params = CGI::parse( @params = CGI::parse(
@ -951,7 +951,7 @@ convert string charset, and set language to "ja".
lines = string.gsub(/(?!\A)<(?:.|\n)*?>/n, "\n\\0").gsub(/<(?:.|\n)*?>(?!\n)/n, "\\0\n") lines = string.gsub(/(?!\A)<(?:.|\n)*?>/n, "\n\\0").gsub(/<(?:.|\n)*?>(?!\n)/n, "\\0\n")
end_pos = 0 end_pos = 0
while end_pos = lines.index(/^<\/(\w+)/n, end_pos) while end_pos = lines.index(/^<\/(\w+)/n, end_pos)
element = $1.dup element = Regexp::last_match[1].dup
start_pos = lines.rindex(/^\s*<#{element}/ni, end_pos) start_pos = lines.rindex(/^\s*<#{element}/ni, end_pos)
lines[start_pos ... end_pos] = "__" + lines[start_pos ... end_pos].gsub(/\n(?!\z)/n, "\n" + shift) + "__" lines[start_pos ... end_pos] = "__" + lines[start_pos ... end_pos].gsub(/\n(?!\z)/n, "\n" + shift) + "__"
end end
@ -1925,6 +1925,15 @@ end
== HISTORY == HISTORY
* Mon Dec 11 00:16:51 JST 2000 - wakou
* version 2.1.1
* support -T1 on ruby 1.6.2
* body.original_filename: eval(str.dump.untaint).taint
* body.content_type: eval(str.dump.untaint).taint
* $& --> Regexp::last_match[0]
* $1 --> Regexp::last_match[1]
* $2 --> Regexp::last_match[2]
* Thu Oct 12 01:16:59 JST 2000 - wakou * Thu Oct 12 01:16:59 JST 2000 - wakou
* version 2.1.0 * version 2.1.0
* bug fix: CGI::html(): PRETTY option didn't work. * bug fix: CGI::html(): PRETTY option didn't work.

View file

@ -4,7 +4,7 @@
net/telnet.rb - simple telnet client library net/telnet.rb - simple telnet client library
Version 1.6.0 Version 1.6.1
Wakou Aoyama <wakou@fsinet.or.jp> Wakou Aoyama <wakou@fsinet.or.jp>
@ -239,10 +239,10 @@ module Net
CR = "\015" CR = "\015"
LF = "\012" LF = "\012"
EOL = CR + LF EOL = CR + LF
VERSION = "1.6.0" VERSION = "1.6.1"
RELEASE_DATE = "2000-09-12" RELEASE_DATE = "2000-12-14"
VERSION_CODE = 160 VERSION_CODE = 161
RELEASE_CODE = 20000912 RELEASE_CODE = 20001214
def initialize(options) def initialize(options)
@options = options @options = options
@ -398,42 +398,42 @@ module Net
[#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}]| [#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}]|
#{SB}[^#{IAC}]*#{IAC}#{SE} #{SB}[^#{IAC}]*#{IAC}#{SE}
)/xno) do )/xno) do
if IAC == $1 # handle escaped IAC characters if IAC == Regexp::last_match[1] # handle escaped IAC characters
IAC IAC
elsif AYT == $1 # respond to "IAC AYT" (are you there) elsif AYT == Regexp::last_match[1] # respond to "IAC AYT" (are you there)
self.write("nobody here but us pigeons" + EOL) self.write("nobody here but us pigeons" + EOL)
'' ''
elsif DO[0] == $1[0] # respond to "IAC DO x" elsif DO[0] == Regexp::last_match[1][0] # respond to "IAC DO x"
if OPT_BINARY[0] == $1[1] if OPT_BINARY[0] == Regexp::last_match[1][1]
@telnet_option["BINARY"] = true @telnet_option["BINARY"] = true
self.write(IAC + WILL + OPT_BINARY) self.write(IAC + WILL + OPT_BINARY)
else else
self.write(IAC + WONT + $1[1..1]) self.write(IAC + WONT + Regexp::last_match[1][1..1])
end end
'' ''
elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x" elsif DONT[0] == Regexp::last_match[1][0] # respond to "IAC DON'T x" with "IAC WON'T x"
self.write(IAC + WONT + $1[1..1]) self.write(IAC + WONT + Regexp::last_match[1][1..1])
'' ''
elsif WILL[0] == $1[0] # respond to "IAC WILL x" elsif WILL[0] == Regexp::last_match[1][0] # respond to "IAC WILL x"
if OPT_BINARY[0] == $1[1] if OPT_BINARY[0] == Regexp::last_match[1][1]
self.write(IAC + DO + OPT_BINARY) self.write(IAC + DO + OPT_BINARY)
elsif OPT_ECHO[0] == $1[1] elsif OPT_ECHO[0] == Regexp::last_match[1][1]
self.write(IAC + DO + OPT_ECHO) self.write(IAC + DO + OPT_ECHO)
elsif OPT_SGA[0] == $1[1] elsif OPT_SGA[0] == Regexp::last_match[1][1]
@telnet_option["SGA"] = true @telnet_option["SGA"] = true
self.write(IAC + DO + OPT_SGA) self.write(IAC + DO + OPT_SGA)
else else
self.write(IAC + DONT + $1[1..1]) self.write(IAC + DONT + Regexp::last_match[1][1..1])
end end
'' ''
elsif WONT[0] == $1[0] # respond to "IAC WON'T x" elsif WONT[0] == Regexp::last_match[1][0] # respond to "IAC WON'T x"
if OPT_ECHO[0] == $1[1] if OPT_ECHO[0] == Regexp::last_match[1][1]
self.write(IAC + DONT + OPT_ECHO) self.write(IAC + DONT + OPT_ECHO)
elsif OPT_SGA[0] == $1[1] elsif OPT_SGA[0] == Regexp::last_match[1][1]
@telnet_option["SGA"] = false @telnet_option["SGA"] = false
self.write(IAC + DONT + OPT_SGA) self.write(IAC + DONT + OPT_SGA)
else else
self.write(IAC + DONT + $1[1..1]) self.write(IAC + DONT + Regexp::last_match[1][1..1])
end end
'' ''
else else
@ -599,6 +599,10 @@ end
== HISTORY == HISTORY
* Mon Dec 11 00:16:51 JST 2000 - wakou
* version 1.6.1
* $1 --> Regexp::last_match[1]
* 2000/09/12 05:37:35 - matz * 2000/09/12 05:37:35 - matz
* change: iterator? --> block_given? * change: iterator? --> block_given?