Skip to content

* lib/webrick/httpservlet/filehandler.rb: some fix on win platform or not utf-8 platform #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/webrick/httpservlet/filehandler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def set_filename(req, res)
end

if base = path_info.first
if base == "/"
if base == "/" or base == ""
if file = search_index_file(req, res)
shift_path_info(req, res, path_info, file)
call_callback(:FileCallback, req, res)
Expand Down Expand Up @@ -408,7 +408,7 @@ def set_dir_list(req, res)
unless @options[:FancyIndexing]
raise HTTPStatus::Forbidden, "no access permission to `#{req.path}'"
end
local_path = res.filename
local_path = res.filename.dup.force_encoding(Encoding.find("filesystem"))
list = Dir::entries(local_path).collect{|name|
next if name == "." || name == ".."
next if nondisclosure_name?(name)
Expand Down Expand Up @@ -499,7 +499,7 @@ def set_dir_list(req, res)
s = "<TR><TD class=\"name\"><A HREF=\"#{HTTPUtils::escape(name)}\">#{HTMLUtils::escape(dname)}</A></TD>"
s << "<TD class=\"mtime\">" << (time ? time.strftime("%Y/%m/%d %H:%M") : "") << "</TD>"
s << "<TD class=\"size\">" << (size >= 0 ? size.to_s : "-") << "</TD></TR>\n"
res.body << s
res.body << s.force_encoding(res.body.encoding)
}
res.body << "</TBODY></TABLE>"
res.body << "<HR>"
Expand Down