зеркало из https://github.com/github/ruby.git
* lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
should log about all accepted socket. [ruby-core:03962] * lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params): "%%" and "%u" are supported. [webricken:135] * lib/webrick/httpservlet/filehandler.rb (WEBrick::HTTPServlet::FileHandler#check_filename): :NondisclosureName is acceptable if it is Enumerable. * lib/webrick/config.rb (WEBrick::Config::FileHandler): default value of :NondisclosureName is [".ht*", "*~"]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2edbb9d0f8
Коммит
52d91fa402
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
Wed Dec 15 17:47:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
|
||||
should log about all accepted socket. [ruby-core:03962]
|
||||
|
||||
* lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params):
|
||||
"%%" and "%u" are supported. [webricken:135]
|
||||
|
||||
* lib/webrick/httpservlet/filehandler.rb
|
||||
(WEBrick::HTTPServlet::FileHandler#check_filename):
|
||||
:NondisclosureName is acceptable if it is Enumerable.
|
||||
|
||||
* lib/webrick/config.rb (WEBrick::Config::FileHandler):
|
||||
default value of :NondisclosureName is [".ht*", "*~"].
|
||||
|
||||
Wed Dec 15 15:31:02 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/set.rb (Set#==): [ruby-dev:25206]
|
||||
|
|
|
@ -32,6 +32,7 @@ module WEBrick
|
|||
params["i"] = req
|
||||
params["l"] = "-"
|
||||
params["m"] = req.request_method
|
||||
params["n"] = req.attributes
|
||||
params["o"] = res
|
||||
params["p"] = req.port
|
||||
params["q"] = req.query_string
|
||||
|
@ -46,15 +47,17 @@ module WEBrick
|
|||
end
|
||||
|
||||
def format(format_string, params)
|
||||
format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z])/){
|
||||
format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z%])/){
|
||||
param, spec = $1, $2
|
||||
case spec[0]
|
||||
when ?e, ?i, ?o
|
||||
when ?e, ?i, ?n, ?o
|
||||
raise AccessLogError,
|
||||
"parameter is required for \"#{spec}\"" unless param
|
||||
params[spec][param] || "-"
|
||||
when ?t
|
||||
params[spec].strftime(param || CLF_TIME_FORMAT)
|
||||
when ?%
|
||||
"%"
|
||||
else
|
||||
params[spec]
|
||||
end
|
||||
|
|
|
@ -65,7 +65,7 @@ module WEBrick
|
|||
)
|
||||
|
||||
FileHandler = {
|
||||
:NondisclosureName => ".ht*",
|
||||
:NondisclosureName => [".ht*", "*~"],
|
||||
:FancyIndexing => false,
|
||||
:HandlerTable => {},
|
||||
:HandlerCallback => nil,
|
||||
|
|
|
@ -226,7 +226,7 @@ module WEBrick
|
|||
|
||||
path_info.unshift("") # dummy for checking @root dir
|
||||
while base = path_info.first
|
||||
check_filename(base)
|
||||
check_filename(req, res, base)
|
||||
break if base == "/"
|
||||
break unless File.directory?(res.filename + base)
|
||||
shift_path_info(req, res, path_info)
|
||||
|
@ -234,7 +234,7 @@ module WEBrick
|
|||
end
|
||||
|
||||
if base = path_info.first
|
||||
check_filename(base)
|
||||
check_filename(req, res, base)
|
||||
if base == "/"
|
||||
if file = search_index_file(req, res)
|
||||
shift_path_info(req, res, path_info, file)
|
||||
|
@ -254,11 +254,13 @@ module WEBrick
|
|||
return false
|
||||
end
|
||||
|
||||
def check_filename(name)
|
||||
if File.fnmatch("/#{@options[:NondisclosureName]}", name)
|
||||
@logger.warn("the request refers nondisclosure name `#{name}'.")
|
||||
raise HTTPStatus::NotFound, "`#{req.path}' not found."
|
||||
end
|
||||
def check_filename(req, res, name)
|
||||
@options[:NondisclosureName].each{|pattern|
|
||||
if File.fnmatch("/#{pattern}", name)
|
||||
@logger.warn("the request refers nondisclosure name `#{name}'.")
|
||||
raise HTTPStatus::NotFound, "`#{req.path}' not found."
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def shift_path_info(req, res, path_info, base=nil)
|
||||
|
@ -306,6 +308,15 @@ module WEBrick
|
|||
end
|
||||
end
|
||||
|
||||
def nondisclosure_name?(name)
|
||||
@options[:NondisclosureName].each{|pattern|
|
||||
if File.fnmatch(pattern, name)
|
||||
return true
|
||||
end
|
||||
}
|
||||
return false
|
||||
end
|
||||
|
||||
def set_dir_list(req, res)
|
||||
redirect_to_directory_uri(req, res)
|
||||
unless @options[:FancyIndexing]
|
||||
|
@ -314,7 +325,7 @@ module WEBrick
|
|||
local_path = res.filename
|
||||
list = Dir::entries(local_path).collect{|name|
|
||||
next if name == "." || name == ".."
|
||||
next if File::fnmatch(@options[:NondisclosureName], name)
|
||||
next if nondisclosure_name?(name)
|
||||
st = (File::stat(local_path + name) rescue nil)
|
||||
if st.nil?
|
||||
[ name, nil, -1 ]
|
||||
|
|
|
@ -147,8 +147,13 @@ module WEBrick
|
|||
Thread.start{
|
||||
begin
|
||||
Thread.current[:WEBrickSocket] = sock
|
||||
addr = sock.peeraddr
|
||||
@logger.debug "accept: #{addr[3]}:#{addr[1]}"
|
||||
begin
|
||||
addr = sock.peeraddr
|
||||
@logger.debug "accept: #{addr[3]}:#{addr[1]}"
|
||||
rescue SocketError
|
||||
@logger.debug "accept: <address unknown>"
|
||||
raise
|
||||
end
|
||||
call_callback(:AcceptCallback, sock)
|
||||
block ? block.call(sock) : run(sock)
|
||||
rescue Errno::ENOTCONN
|
||||
|
|
Загрузка…
Ссылка в новой задаче