* lib/cgi.rb: CGI#doctype(): bug fix (html4Fr).

* lib/net/telnet.rb, lib/cgi.rb: remove VERSION, RELEASE_DATE,
	  VERSION_CODE, RELEASE_CODE. please use REVISION.

	* lib/cgi.rb: CGI#header(): bug fix.

	* lib/net/telnet.rb, lib/cgi.rb: concat --> +=


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
wakou 2001-09-06 22:18:11 +00:00
parent aebf069adf
commit 749f0f9255
3 changed files with 72 additions and 77 deletions

View File

@ -1,3 +1,14 @@
Fri Sep 7 07:11:34 2001 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/cgi.rb: CGI#doctype(): bug fix (html4Fr).
* lib/net/telnet.rb, lib/cgi.rb: remove VERSION, RELEASE_DATE,
VERSION_CODE, RELEASE_CODE. please use REVISION.
* lib/cgi.rb: CGI#header(): bug fix.
* lib/net/telnet.rb, lib/cgi.rb: concat --> +=
Thu Sep 6 17:38:18 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> Thu Sep 6 17:38:18 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* dir.c (dir_s_chdir): raise if environment variable HOME/LOGDIR * dir.c (dir_s_chdir): raise if environment variable HOME/LOGDIR

View File

@ -4,8 +4,6 @@
cgi.rb - cgi support library cgi.rb - cgi support library
Version 2.1.4
Copyright (C) 2000 Network Applied Communication Laboratory, Inc. Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan Copyright (C) 2000 Information-technology Promotion Agency, Japan
@ -169,9 +167,9 @@ HTTP_REFERER HTTP_USER_AGENT
# add HTML generation methods # add HTML generation methods
CGI.new("html3") # html3.2 CGI.new("html3") # html3.2
CGI.new("html4") # html4.0 (Strict) CGI.new("html4") # html4.01 (Strict)
CGI.new("html4Tr") # html4.0 Transitional CGI.new("html4Tr") # html4.01 Transitional
CGI.new("html4Fr") # html4.0 Frameset CGI.new("html4Fr") # html4.01 Frameset
=end =end
@ -185,10 +183,6 @@ class CGI
CR = "\015" CR = "\015"
LF = "\012" LF = "\012"
EOL = CR + LF EOL = CR + LF
VERSION = '2.1.4'
RELEASE_DATE = '2001-04-18'
VERSION_CODE = 214
RELEASE_CODE = 20010418
REVISION = '$Id$' REVISION = '$Id$'
NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM) NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM)
@ -411,8 +405,11 @@ status:
buf = "" buf = ""
if options.kind_of?(String) case options
when String
options = { "type" => options } options = { "type" => options }
when Hash
options = options.dup
end end
unless options.has_key?("type") unless options.has_key?("type")
@ -420,21 +417,15 @@ status:
end end
if options.has_key?("charset") if options.has_key?("charset")
options["type"].concat( "; charset=" ) options["type"] += "; charset=" + options.delete("charset")
options["type"].concat( options.delete("charset") )
end end
options.delete("nph") if defined?(MOD_RUBY) options.delete("nph") if defined?(MOD_RUBY)
if options.delete("nph") or /IIS/n.match(env_table['SERVER_SOFTWARE']) if options.delete("nph") or /IIS/n.match(env_table['SERVER_SOFTWARE'])
buf.concat( (env_table["SERVER_PROTOCOL"] or "HTTP/1.0") + " " ) buf += (env_table["SERVER_PROTOCOL"] or "HTTP/1.0") + " " +
buf.concat( (HTTP_STATUS[options["status"]] or (HTTP_STATUS[options["status"]] or options["status"] or "200 OK") +
options["status"] or EOL +
"200 OK"
) + EOL
)
buf.concat(
"Date: " + CGI::rfc1123_date(Time.now) + EOL "Date: " + CGI::rfc1123_date(Time.now) + EOL
)
unless options.has_key?("server") unless options.has_key?("server")
options["server"] = (env_table['SERVER_SOFTWARE'] or "") options["server"] = (env_table['SERVER_SOFTWARE'] or "")
@ -448,55 +439,55 @@ status:
end end
if options.has_key?("status") if options.has_key?("status")
status = (HTTP_STATUS[options["status"]] or options["status"]) buf += "Status: " +
buf.concat("Status: " + status + EOL) (HTTP_STATUS[options["status"]] or options["status"]) + EOL
options.delete("status") options.delete("status")
end end
if options.has_key?("server") if options.has_key?("server")
buf.concat("Server: " + options.delete("server") + EOL) buf += "Server: " + options.delete("server") + EOL
end end
if options.has_key?("connection") if options.has_key?("connection")
buf.concat("Connection: " + options.delete("connection") + EOL) buf += "Connection: " + options.delete("connection") + EOL
end end
buf.concat("Content-Type: " + options.delete("type") + EOL) buf += "Content-Type: " + options.delete("type") + EOL
if options.has_key?("length") if options.has_key?("length")
buf.concat("Content-Length: " + options.delete("length").to_s + EOL) buf += "Content-Length: " + options.delete("length").to_s + EOL
end end
if options.has_key?("language") if options.has_key?("language")
buf.concat("Content-Language: " + options.delete("language") + EOL) buf += "Content-Language: " + options.delete("language") + EOL
end end
if options.has_key?("expires") if options.has_key?("expires")
buf.concat("Expires: " + CGI::rfc1123_date( options.delete("expires") ) + EOL) buf += "Expires: " + CGI::rfc1123_date( options.delete("expires") ) + EOL
end end
if options.has_key?("cookie") if options.has_key?("cookie")
if options["cookie"].kind_of?(String) or if options["cookie"].kind_of?(String) or
options["cookie"].kind_of?(Cookie) options["cookie"].kind_of?(Cookie)
buf.concat("Set-Cookie: " + options.delete("cookie").to_s + EOL) buf += "Set-Cookie: " + options.delete("cookie").to_s + EOL
elsif options["cookie"].kind_of?(Array) elsif options["cookie"].kind_of?(Array)
options.delete("cookie").each{|cookie| options.delete("cookie").each{|cookie|
buf.concat("Set-Cookie: " + cookie.to_s + EOL) buf += "Set-Cookie: " + cookie.to_s + EOL
} }
elsif options["cookie"].kind_of?(Hash) elsif options["cookie"].kind_of?(Hash)
options.delete("cookie").each_value{|cookie| options.delete("cookie").each_value{|cookie|
buf.concat("Set-Cookie: " + cookie.to_s + EOL) buf += "Set-Cookie: " + cookie.to_s + EOL
} }
end end
end end
if @output_cookies if @output_cookies
for cookie in @output_cookies for cookie in @output_cookies
buf.concat("Set-Cookie: " + cookie.to_s + EOL) buf += "Set-Cookie: " + cookie.to_s + EOL
end end
end end
options.each{|key, value| options.each{|key, value|
buf.concat(key + ": " + value + EOL) buf += key + ": " + value + EOL
} }
if defined?(MOD_RUBY) if defined?(MOD_RUBY)
@ -663,28 +654,28 @@ convert string charset, and set language to "ja".
def to_s def to_s
buf = "" buf = ""
buf.concat(@name + '=') buf += @name + '='
if @value.kind_of?(String) if @value.kind_of?(String)
buf.concat CGI::escape(@value) buf += CGI::escape(@value)
else else
buf.concat(@value.collect{|v| CGI::escape(v) }.join("&")) buf += @value.collect{|v| CGI::escape(v) }.join("&")
end end
if @domain if @domain
buf.concat('; domain=' + @domain) buf += '; domain=' + @domain
end end
if @path if @path
buf.concat('; path=' + @path) buf += '; path=' + @path
end end
if @expires if @expires
buf.concat('; expires=' + CGI::rfc1123_date(@expires)) buf += '; expires=' + CGI::rfc1123_date(@expires)
end end
if @secure == true if @secure == true
buf.concat('; secure') buf += '; secure'
end end
buf buf
@ -826,7 +817,7 @@ convert string charset, and set language to "ja".
else else
stdinput.read(content_length) or '' stdinput.read(content_length) or ''
end end
buf.concat c buf += c
content_length -= c.size content_length -= c.size
end end
@ -1274,7 +1265,7 @@ The hash keys are case sensitive. Ask the samples.
hidden = @output_hidden.collect{|k,v| hidden = @output_hidden.collect{|k,v|
"<INPUT TYPE=HIDDEN NAME=\"#{k}\" VALUE=\"#{v}\">" "<INPUT TYPE=HIDDEN NAME=\"#{k}\" VALUE=\"#{v}\">"
}.to_s }.to_s
body.concat hidden body += hidden
end end
super(attributes){body} super(attributes){body}
end end
@ -1348,18 +1339,18 @@ The hash keys are case sensitive. Ask the samples.
if attributes.has_key?("DOCTYPE") if attributes.has_key?("DOCTYPE")
if attributes["DOCTYPE"] if attributes["DOCTYPE"]
buf.concat( attributes.delete("DOCTYPE") ) buf += attributes.delete("DOCTYPE")
else else
attributes.delete("DOCTYPE") attributes.delete("DOCTYPE")
end end
else else
buf.concat( doctype ) buf += doctype
end end
if block_given? if block_given?
buf.concat( super(attributes){ yield } ) buf += super(attributes){ yield }
else else
buf.concat( super(attributes) ) buf += super(attributes)
end end
if pretty if pretty
@ -1738,7 +1729,7 @@ The hash keys are case sensitive. Ask the samples.
APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT table TITLE APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT table TITLE
STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE
CAPTION ] CAPTION ]
methods.concat( <<-BEGIN + nn_element_def(element) + <<-END ) methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1748,7 +1739,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY # - O EMPTY
for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
ISINDEX META ] ISINDEX META ]
methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END ) methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1758,7 +1749,7 @@ The hash keys are case sensitive. Ask the samples.
# O O or - O # O O or - O
for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION tr for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION tr
th td ] th td ]
methods.concat( <<-BEGIN + nO_element_def(element) + <<-END ) methods += <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1785,7 +1776,7 @@ The hash keys are case sensitive. Ask the samples.
H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP
FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
TEXTAREA FORM A BLOCKQUOTE CAPTION ] TEXTAREA FORM A BLOCKQUOTE CAPTION ]
methods.concat( <<-BEGIN + nn_element_def(element) + <<-END ) methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1794,7 +1785,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY # - O EMPTY
for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META ] for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META ]
methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END ) methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1804,7 +1795,7 @@ The hash keys are case sensitive. Ask the samples.
# O O or - O # O O or - O
for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
COLGROUP TR TH TD HEAD] COLGROUP TR TH TD HEAD]
methods.concat( <<-BEGIN + nO_element_def(element) + <<-END ) methods += <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1832,7 +1823,7 @@ The hash keys are case sensitive. Ask the samples.
INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET
LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT
NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ] NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ]
methods.concat( <<-BEGIN + nn_element_def(element) + <<-END ) methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1842,7 +1833,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY # - O EMPTY
for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
COL ISINDEX META ] COL ISINDEX META ]
methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END ) methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1852,7 +1843,7 @@ The hash keys are case sensitive. Ask the samples.
# O O or - O # O O or - O
for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
COLGROUP TR TH TD HEAD ] COLGROUP TR TH TD HEAD ]
methods.concat( <<-BEGIN + nO_element_def(element) + <<-END ) methods += <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1871,13 +1862,10 @@ The hash keys are case sensitive. Ask the samples.
end end
def element_init def element_init
extend TagMaker
extend Html4Tr
element_init()
methods = "" methods = ""
# - - # - -
for element in %w[ FRAMESET ] for element in %w[ FRAMESET ]
methods.concat( <<-BEGIN + nn_element_def(element) + <<-END ) methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1886,7 +1874,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY # - O EMPTY
for element in %w[ FRAME ] for element in %w[ FRAME ]
methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END ) methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1925,6 +1913,8 @@ The hash keys are case sensitive. Ask the samples.
element_init() element_init()
extend HtmlExtension extend HtmlExtension
when "html4Fr" when "html4Fr"
extend Html4Tr
element_init()
extend Html4Fr extend Html4Fr
element_init() element_init()
extend HtmlExtension extend HtmlExtension

View File

@ -4,8 +4,6 @@
net/telnet.rb - simple telnet client library net/telnet.rb - simple telnet client library
Version 1.6.3
Wakou Aoyama <wakou@fsinet.or.jp> Wakou Aoyama <wakou@fsinet.or.jp>
@ -239,10 +237,6 @@ module Net
CR = "\015" CR = "\015"
LF = "\012" LF = "\012"
EOL = CR + LF EOL = CR + LF
VERSION = '1.6.3'
RELEASE_DATE = '2001-02-26'
VERSION_CODE = 163
RELEASE_CODE = 20010226
REVISION = '$Id$' REVISION = '$Id$'
def initialize(options) def initialize(options)
@ -291,7 +285,7 @@ module Net
line = x[offset, 16] line = x[offset, 16]
end end
hexvals = line.unpack('H*')[0] hexvals = line.unpack('H*')[0]
hexvals.concat ' ' * (32 - hexvals.length) hexvals += ' ' * (32 - hexvals.length)
hexvals = format "%s %s %s %s " * 4, *hexvals.unpack('a2' * 16) hexvals = format "%s %s %s %s " * 4, *hexvals.unpack('a2' * 16)
line = line.gsub(/[\000-\037\177-\377]/n, '.') line = line.gsub(/[\000-\037\177-\377]/n, '.')
printf "%s 0x%5.5x: %s%s\n", dir, addr, hexvals, line printf "%s 0x%5.5x: %s%s\n", dir, addr, hexvals, line
@ -487,7 +481,7 @@ module Net
end end
end end
@log.print(buf) if @options.has_key?("Output_log") @log.print(buf) if @options.has_key?("Output_log")
line.concat(buf) line += buf
yield buf if block_given? yield buf if block_given?
rescue EOFError # End of file reached rescue EOFError # End of file reached
if line == '' if line == ''
@ -571,20 +565,20 @@ module Net
if block_given? if block_given?
line = waitfor(/login[: ]*\z/n){|c| yield c } line = waitfor(/login[: ]*\z/n){|c| yield c }
if password if password
line.concat( cmd({"String" => username, line += cmd({"String" => username,
"Match" => /Password[: ]*\z/n}){|c| yield c } ) "Match" => /Password[: ]*\z/n}){|c| yield c }
line.concat( cmd(password){|c| yield c } ) line += cmd(password){|c| yield c }
else else
line.concat( cmd(username){|c| yield c } ) line += cmd(username){|c| yield c }
end end
else else
line = waitfor(/login[: ]*\z/n) line = waitfor(/login[: ]*\z/n)
if password if password
line.concat( cmd({"String" => username, line += cmd({"String" => username,
"Match" => /Password[: ]*\z/n}) ) "Match" => /Password[: ]*\z/n})
line.concat( cmd(password) ) line += cmd(password)
else else
line.concat( cmd(username) ) line += cmd(username)
end end
end end
line line