about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--extras/autoindex.rb2
-rw-r--r--test/test_extras_autoindex.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/extras/autoindex.rb b/extras/autoindex.rb
index c8f7054..0ae7260 100644
--- a/extras/autoindex.rb
+++ b/extras/autoindex.rb
@@ -71,6 +71,8 @@ class Autoindex
         case base
         when "."
           next
+        when ".."
+          next if path_info == "/"
         end
 
         begin
diff --git a/test/test_extras_autoindex.rb b/test/test_extras_autoindex.rb
index ed0e1d5..e17234f 100644
--- a/test/test_extras_autoindex.rb
+++ b/test/test_extras_autoindex.rb
@@ -44,8 +44,12 @@ class TestExtrasAutoindex < Testcase
 
       res = http.request(Net::HTTP::Get.new("/"))
       assert_equal 200, res.code.to_i
+      refute_match %r{\.\./}, res.body, "top level should not link to parent"
       assert_match %r{foo}, res.body
-      assert_match %r{bar/}, res.body
+
+      res = http.request(Net::HTTP::Get.new("/bar/"))
+      assert_equal 200, res.code.to_i
+      assert_match %r{\.\./}, res.body, "link to parent present"
     end
   ensure
     quit_wait pid