summaryrefslogtreecommitdiffstats
path: root/lib/webrick/httpservlet
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-15 08:47:49 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-15 08:47:49 +0000
commit9eea7fdc5b5a96d97018c6070898781e264c034f (patch)
tree587704d3bfe1797863ec5cd7bab2ab5b49c95ac4 /lib/webrick/httpservlet
parentd611b85c09d15fce570bfb424ee8c1290e93df35 (diff)
downloadruby-9eea7fdc5b5a96d97018c6070898781e264c034f.tar.gz
ruby-9eea7fdc5b5a96d97018c6070898781e264c034f.tar.xz
ruby-9eea7fdc5b5a96d97018c6070898781e264c034f.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@7566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpservlet')
-rw-r--r--lib/webrick/httpservlet/filehandler.rb27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 1c4873498..ba9417f3e 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -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 ]