# File lib/mongrel/handlers.rb, line 129 def can_serve(path_info) req_path = HttpRequest.unescape(path_info) # Add the drive letter or root path req_path = File.join(@path, req_path) if @path req_path = File.expand_path req_path # do not remove the check for @path at the beginning, it's what prevents # the serving of arbitrary files (and good programmer Rule #1 Says: If # you don't understand something, it's not because I'm stupid, it's # because you are). if req_path.index(@path) == 0 and File.exist? req_path # It exists and it's in the right location if File.directory? req_path # The request is for a directory index = File.join(req_path, @index_html) if File.exist? index # Serve the index return index elsif @listing_allowed # Serve the directory return req_path else # Do not serve anything return nil end else # It's a file and it's there return req_path end else # does not exist or isn't in the right spot or isn't valid because not start with @path return nil end end