diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index 0bb1fb864f..467b64f0c3 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -424,11 +424,18 @@ module WEBrick } list.compact! - if d0 = req.query["N"]; idx = 0 - elsif d0 = req.query["M"]; idx = 1 - elsif d0 = req.query["S"]; idx = 2 - else d0 = "A" ; idx = 0 + query = req.query + + d0 = nil + idx = nil + %w[N M S].each_with_index do |q, i| + if d = query.delete(q) + idx ||= i + d0 ||= d + end end + d0 ||= "A" + idx ||= 0 d1 = (d0 == "A") ? "D" : "A" if d0 == "A" @@ -437,6 +444,14 @@ module WEBrick list.sort!{|a,b| b[idx] <=> a[idx] } end + namewidth = query["NameWidth"] + if namewidth == "*" + namewidth = nil + elsif !namewidth or (namewidth = namewidth.to_i) < 2 + namewidth = 25 + end + query = query.inject('') {|s, (k, v)| s << '&' << HTMLUtils::escape("#{k}=#{v}")} + type = "text/html" case enc = Encoding.find('filesystem') when Encoding::US_ASCII, Encoding::ASCII_8BIT @@ -455,6 +470,7 @@ module WEBrick @@ -465,9 +481,9 @@ module WEBrick _end_of_html_ res.body << "
Name | " - res.body << "Last modified | " - res.body << "Size | \n" + res.body << "Name | " + res.body << "Last modified | " + res.body << "Size | \n" res.body << "
---|---|---|---|---|---|
#{HTMLUtils::escape(dname)} | " s << "" << (time ? time.strftime("%Y/%m/%d %H:%M") : "") << " | "