about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-09-01 22:45:21 +0000
committerEric Wong <e@80x24.org>2014-09-01 22:45:21 +0000
commitef16914521dda4fcc8ee77ab44696fa58b749d37 (patch)
tree0d26d9dde1cc546ddd1d550d212a1f754d826260
parentf7870c9f6ee2814391d234d7a2c84fb91277caab (diff)
downloadyahns-ef16914521dda4fcc8ee77ab44696fa58b749d37.tar.gz
No need to waste space on this (and trigger "Bad partial
reference!" warnings on lynx)
-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