* [PATCH] extras/autoindex: do not link beyond top-level
@ 2014-09-01 22:48 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2014-09-01 22:48 UTC (permalink / raw)
To: yahns-public; +Cc: Eric Wong
No need to waste space on this (and trigger "Bad partial
reference!" warnings on lynx)
---
| 2 ++
| 6 +++++-
2 files changed, 7 insertions(+), 1 deletion(-)
--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
--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
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-09-01 22:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-01 22:48 [PATCH] extras/autoindex: do not link beyond top-level Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/yahns.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).