class Rack::Directory

def check_forbidden(path_info)

Rack response to use for requests with paths outside the root, or nil if path is inside the root.
def check_forbidden(path_info)
  return unless path_info.include? ".."
  return if ::File.expand_path(::File.join(@root, path_info)).start_with?(@root)
  body = "Forbidden\n"
  [403, { CONTENT_TYPE => "text/plain",
    CONTENT_LENGTH => body.bytesize.to_s,
    "x-cascade" => "pass" }, [body]]
end