about summary refs log tree commit homepage
path: root/extras/try_gzip_static.rb
diff options
context:
space:
mode:
Diffstat (limited to 'extras/try_gzip_static.rb')
-rw-r--r--extras/try_gzip_static.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/extras/try_gzip_static.rb b/extras/try_gzip_static.rb
index 31c1aa1..ed561cb 100644
--- a/extras/try_gzip_static.rb
+++ b/extras/try_gzip_static.rb
@@ -92,7 +92,12 @@ class TryGzipStatic
   def stat_path(env)
     path = fspath(env) or return r(403)
     begin
-      st = File.stat(path)
+      st = File.lstat(path)
+      if st.symlink?
+        path = File.readlink(path)
+        path[0] == '/'.freeze or path = "#@root/#{path}"
+        st = File.stat(path)
+      end
       return r(404) unless st.file?
       return r(403) unless st.readable?
       [ path, st ]