8000 wakou · jruby/ruby@652f744 · GitHub
[go: up one dir, main page]

Skip to content

Commit 652f744

Browse files
author
wakou
committed
wakou
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 3e865dc commit 652f744

File tree

3 files changed

+74
-53
lines changed

3 files changed

+74
-53
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Thu Dec 14 09:20:26 2000 Wakou Aoyama <wakou@fsinet.or.jp>
2+
3+
* lib/cgi.rb: support -T1 on ruby 1.6.2
4+
5+
* lib/cgi.rb: $1 --> Regexp::last_match[1]
6+
7+
* lib/net/telnet.rb: ditto.
8+
19
Wed Dec 13 12:41:27 2000 WATANABE Hirofumi <eban@ruby-lang.org>
210

311
* ruby.c (proc_options): accept "--^M" for DOS line endings.

lib/cgi.rb

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
cgi.rb - cgi support library
66
7-
Version 2.1.0
7+
Version 2.1.1
88
99
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
1010
@@ -185,10 +185,10 @@ class CGI
185185
CR = "\015"
186186
LF = "\012"
187187
EOL = CR + LF
188-
VERSION = "2.1.0"
189-
RELEASE_DATE = "2000-10-12"
190-
VERSION_CODE = 210
191-
RELEASE_CODE = 20001012
188+
VERSION = "2.1.1"
189+
RELEASE_DATE = "2000-12-14"
190+
VERSION_CODE = 211
191+
RELEASE_CODE = 20001214
192192

193193
NEEDS_BINMODE = true if /WIN/ni === RUBY_PLATFORM
194194
PATH_SEPARATOR = {'UNIX'=>'/', 'WINDOWS'=>'\\', 'MACINTOSH'=>':'}
@@ -241,7 +241,7 @@ def stdoutput
241241
=end
242242
def CGI::escape(string)
243243
string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
244-
'%' + $1.unpack('H2' * $1.size).join('%').upcase
244+
'%' + Regexp::last_match[1].unpack('H2' * Regexp::last_match[1].size).join('%').upcase
245245
end.tr(' ', '+')
246246
end
247247

@@ -252,7 +252,7 @@ def CGI::escape(string)
252252
=end
253253
def CGI::unescape(string)
254254
string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do
255-
[$1.delete('%')].pack('H*')
255+
[Regexp::last_match[1].delete('%')].pack('H*')
256256
end
257257
end
258258

@@ -272,34 +272,34 @@ def CGI::escapeHTML(string)
272272
=end
273273
def CGI::unescapeHTML(string)
274274
string.gsub(/&(.*?);/n) do
275-
match = $1.dup
275+
match = Regexp::last_match[1].dup
276276
case match
277277
when /\Aamp\z/ni then '&'
278278
when /\Aquot\z/ni then '"'
279279
when /\Agt\z/ni then '>'
280280
when /\Alt\z/ni then '<'
281281
when /\A#(\d+)\z/n then
282-
if Integer($1) < 256
283-
Integer($1).chr
282+
if Integer(Regexp::last_match[1]) < 256
283+
Integer(Regexp::last_match[1]).chr
284284
else
285-
if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
286-
[Integer($1)].pack("U")
285+
if Integer(Regexp::last_match[1]) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
286+
[Integer(Regexp::last_match[1])].pack("U")
287287
else
288-
"&##{$1};"
288+
"&##{Regexp::last_match[1]};"
289289
end
290290
end
291291
when /\A#x([0-9a-f]+)\z/ni then
292-
if $1.hex < 256
293-
$1.hex.chr
292+
if Regexp::last_match[1].hex < 256
293+
Regexp::last_match[1].hex.chr
294294
else
295-
if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
296-
[$1.hex].pack("U")
295+
if Regexp::last_match[1].hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
296+
[Regexp::last_match[1].hex].pack("U")
297297
else
298-
"&#x#{$1};"
298+
"&#x#{Regexp::last_match[1]};"
299299
end
300300
end
301301
else
302-
"&#{$1};"
302+
"&#{Regexp::last_match[1]};"
303303
end
304304
end
305305
end
@@ -316,7 +316,7 @@ def CGI::unescapeHTML(string)
316316
def CGI::escapeElement(string, *element)
317317
unless element.empty?
318318
string.gsub(/<\/?(?:#{element.join("|")})(?!\w)(?:.|\n)*?>/ni) do
319-
CGI::escapeHTML($&)
319+
CGI::escapeHTML(Regexp::last_match[0])
320320
end
321321
else
322322
string
@@ -336,7 +336,7 @@ def CGI::escapeElement(string, *element)
336336
=end
337337
def CGI::unescapeElement(string, *element)
338338
string.gsub(/&lt;\/?(?:#{element.join("|")})(?!\w)(?:.|\n)*?&gt;/ni) do
339-
CGI::unescapeHTML($&)
339+
CGI::unescapeHTML(Regexp::last_match[0])
340340
end
341341
end
342342

@@ -491,7 +491,7 @@ def header(options = "text/html")
491491

492492
if defined?(MOD_RUBY)
493493
buf.scan(/([^:]+): (.+)#{EOL}/n){
494-
Apache::request[$1] = $2
494+
Apache::request[Regexp::last_match[1]] = Regexp::last_match[2]
495495
}
496496
Apache::request.send_http_header
497497
''
@@ -787,7 +787,7 @@ def read_multipart(boundary, content_length)
787787

788788
if (not head) and (/#{EOL}#{EOL}/n === buf)
789789
buf = buf.sub(/\A((?:.|\n)*?#{EOL})#{EOL}/n) do
790-
head = $1.dup
790+
head = Regexp::last_match[1].dup
791791
""
792792
end
793793
next
@@ -809,8 +809,8 @@ def read_multipart(boundary, content_length)
809809
end
810810

811811
buf = buf.sub(/\A((?:.|\n)*?)(?:#{EOL})?#{boundary}(#{EOL}|--)/n) do
812-
body.print $1
813-
if "--" == $2
812+
body.print Regexp::last_match[1]
813+
if "--" == Regexp::last_match[2]
814814
content_length = -1
815815
end
816816
""
@@ -828,27 +828,27 @@ def body.local_path
828828
eval <<-END
829829
def body.original_filename
830830
#{
831-
filename = ($1 or "").dup
831+
filename = (Regexp::last_match[1] or "").dup
832832
if (/Mac/ni === env_table['HTTP_USER_AGENT']) and
833833
(/Mozilla/ni === env_table['HTTP_USER_AGENT']) and
834834
(not /MSIE/ni === env_table['HTTP_USER_AGENT'])
835835
CGI::unescape(filename)
836836
else
837837
filename
838-
end.dump
839-
}
838+
end.dump.untaint
839+
}.taint
840840
end
841841
END
842842

843843
/Content-Type: (.*)/ni === head
844844
eval <<-END
845845
def body.content_type
846-
#{($1 or "").dump}
846+
#{(Regexp::last_match[1] or "").dump.untaint}.taint
847847
end
848848
END
849849

850850
/Content-Disposition:.* name="?([^\";]*)"?/ni === head
851-
name = $1.dup
851+
name = Regexp::last_match[1].dup
852852

853853
if params.has_key?(name)
854854
params[name].push(body)
@@ -891,7 +891,7 @@ def initialize_query()
891891
if ("POST" == env_table['REQUEST_METHOD']) and
892892
(%r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n ===
893893
env_table['CONTENT_TYPE'])
894-
boundary = $1.dup
894+
boundary = Regexp::last_match[1].dup
895895
@params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
896896
else
897897
@params = CGI::parse(
@@ -951,7 +951,7 @@ def CGI::pretty(string, shift = " ")
951951
lines = string.gsub(/(?!\A)<(?:.|\n)*?>/n, "\n\\0").gsub(/<(?:.|\n)*?>(?!\n)/n, "\\0\n")
952952
end_pos = 0
953953
while end_pos = lines.index(/^<\/(\w+)/n, end_pos)
954-
element = $1.dup
954+
element = Regexp::last_match[1].dup
955955
start_pos = lines.rindex(/^\s*<#{element}/ni, end_pos)
956956
lines[start_pos ... end_pos] = "__" + lines[start_pos ... end_pos].gsub(/\n(?!\z)/n, "\n" + shift) + "__"
957957
end
@@ -1925,6 +1925,15 @@ def initialize(type = "query")
19251925
19261926
== HISTORY
19271927
1928+
* Mon Dec 11 00:16:51 JST 2000 - wakou
1929+
* version 2.1.1
1930+
* support -T1 on ruby 1.6.2
1931+
* body.original_filename: eval(str.dump.untaint).taint
1932+
* body.content_type: eval(str.dump.untaint).taint
1933+
* $& --> Regexp::last_match[0]
1934+
* $1 --> Regexp::last_match[1]
1935+
* $2 --> Regexp::last_match[2]
1936+
19281937
* Thu Oct 12 01:16:59 JST 2000 - wakou
19291938
* version 2.1.0
19301939
* bug fix: CGI::html(): PRETTY option didn't work.

lib/net/telnet.rb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
net/telnet.rb - simple telnet client library
66
7-
Version 1.6.0
7+
Version 1.6.1
88
99
Wakou Aoyama <wakou@fsinet.or.jp>
1010
@@ -239,10 +239,10 @@ class Telnet < SimpleDelegator
239239
CR = "\015"
240240
LF = "\012"
241241
EOL = CR + LF
242-
VERSION = "1.6.0"
243-
RELEASE_DATE = "2000-09-12"
244-
VERSION_CODE = 160
245-
RELEASE_CODE = 20000912
242+
VERSION = "1.6.1"
243+
RELEASE_DATE = "2000-12-14"
244+
VERSION_CODE = 161
245+
RELEASE_CODE = 20001214
246246

247247
def initialize(options)
248248
@options = options
@@ -398,42 +398,42 @@ def preprocess(string)
398398
[#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}]|
399399
#{SB}[^#{IAC}]*#{IAC}#{SE}
400400
)/xno) do
401-
if IAC == $1 # handle escaped IAC characters
401+
if IAC == Regexp::last_match[1] # handle escaped IAC characters
402402
IAC
403-
elsif AYT == $1 # respond to "IAC AYT" (are you there)
403+
elsif AYT == Regexp::last_match[1] # respond to "IAC AYT" (are you there)
404404
self.write("nobody here but us pigeons" + EOL)
405405
''
406-
elsif DO[0] == $1[0] # respond to "IAC DO x"
407-
if OPT_BINARY[0] == $1[1]
406+
elsif DO[0] == Regexp::last_match[1][0] # respond to "IAC DO x"
407+
if OPT_BINARY[0] == Regexp::last_match[1][1]
408408
@telnet_option["BINARY"] = true
409409
self.write(IAC + WILL + OPT_BINARY)
410410
else
411-
self.write(IAC + WONT + $1[1..1])
411+
self.write(IAC + WONT + Regexp::last_match[1][1..1])
412412
end
413413
''
414-
elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x"
415-
self.write(IAC + WONT + $1[1..1])
414+
elsif DONT[0] == Regexp::last_match[1][0] # respond to "IAC DON'T x" with "IAC WON'T x"
415+
self.write(IAC + WONT + Regexp::last_match[1][1..1])
416416
''
417-
elsif WILL[0] == $1[0] # respond to "IAC WILL x"
418-
if OPT_BINARY[0] == $1[1]
417+
elsif WILL[0] == Regexp::last_match[1][0] # respond to "IAC WILL x"
418+
if OPT_BINARY[0] == Regexp::last_match[1][1]
419419
self.write(IAC + DO + OPT_BINARY)
420-
elsif OPT_ECHO[0] == $1[1]
420+
elsif OPT_ECHO[0] == Regexp::last_match[1][1]
421421
self.write(IAC + DO + OPT_ECHO)
422-
elsif OPT_SGA[0] == $1[1]
422+
elsif OPT_SGA[0] == Regexp::last_match[1][1]
423423
@telnet_option["SGA"] = true
424424
self.write(IAC + DO + OPT_SGA)
425425
else
426-
self.write(IAC + DONT + $1[1..1])
426+
self.write(IAC + DONT + Regexp::last_match[1][1..1])
427427
end
428428
''
429-
elsif WONT[0] == $1[0] # respond to "IAC WON'T x"
430-
if OPT_ECHO[0] == $1[1]
429+
elsif WONT[0] == Regexp::last_match[1][0] # respond to "IAC WON'T x"
430+
if OPT_ECHO[0] == Regexp::last_match[1][1]
431431
self.write(IAC + DONT + OPT_ECHO)
432-
elsif OPT_SGA[0] == $1[1]
432+
elsif OPT_SGA[0] == Regexp::last_match[1][1]
433433
@telnet_option["SGA"] = false
434434
self.write(IAC + DONT + OPT_SGA)
435435
else
436-
self.write(IAC + DONT + $1[1..1])
436+
self.write(IAC + DONT + Regexp::last_match[1][1..1])
437437
end
438438
''
439439
else
@@ -599,6 +599,10 @@ def login(options, password = nil)
599599
600600
== HISTORY
601601
602+
* Mon Dec 11 00:16:51 JST 2000 - wakou
603+
* version 1.6.1
604+
* $1 --> Regexp::last_match[1]
605+
602606
* 2000/09/12 05:37:35 - matz
603607
* change: iterator? --> block_given?
604608

0 commit comments

Comments
 (0)
0