yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
* [PATCH] extras/try_gzip_static: require readability on HEAD requests
@ 2015-08-14 21:24 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-08-14 21:24 UTC (permalink / raw)
  To: yahns-public

Files may exist and be stat-able, but not readable.  Return
a 403 response for non-readable files.
---
 extras/try_gzip_static.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/extras/try_gzip_static.rb b/extras/try_gzip_static.rb
index d562957..4279e65 100644
--- a/extras/try_gzip_static.rb
+++ b/extras/try_gzip_static.rb
@@ -92,7 +92,9 @@ class TryGzipStatic
     path = fspath(env) or return r(403)
     begin
       st = File.stat(path)
-      st.file? ? [ path, st ] : r(404)
+      return r(404) unless st.file?
+      return r(403) unless st.readable?
+      [ path, st ]
     rescue Errno::ENOENT, Errno::ENOTDIR
       r(404)
     rescue Errno::EACCES
-- 
EW


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-14 21:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-14 21:24 [PATCH] extras/try_gzip_static: require readability on HEAD requests Eric Wong

Code repositories for project(s) associated with this inbox:

	../../../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).