[hunchentoot-devel] handle-static-file patch

Cyrus Harmon ch-tbnl at bobobeach.com
Fri Feb 8 01:36:40 UTC 2008


Currently, if you use create-folder-dispatcher-and-handler to create a  
handler, it will call handle-static-file on a URL like http://bogushost.tld/this/is/a/directory 
  and will give the contents of the directory as returned by fopen'ing  
the directory, which probably isn't what we want. The following patch  
to handle-static-file makes sure that the truename of the file has  
either a pathname-name or a pathname-type.

Not sure if this is desired behavior or not, but I'd rather see a 500  
error here. There's another error where if one sets up a folder- 
dispatcher-and-handler to catch "/www/foo/" and you request "/www/ 
foo/" you git an internal server error instead of a 500 error, but I  
haven't worked out the patch for that one yet.

Thanks,

Cyrus


--- misc.lisp	Thu Feb  7 18:46:24 2008
+++ misc-patched.lisp	Thu Feb  7 18:46:01 2008
@@ -137,11 +137,12 @@
  denoted by PATH.  Send a content type header corresponding to
  CONTENT-TYPE or \(if that is NIL) tries to determine the content
  type via the file's suffix."
-  (unless (or (pathname-name path)
-              (pathname-type path))
-    ;; not a file
-    (setf (return-code) +http-bad-request+)
-    (throw 'handler-done nil))
+  (let ((true-path (truename path)))
+    (unless (or (pathname-name true-path)
+                (pathname-type true-path))
+      ;; not a file
+      (setf (return-code) +http-bad-request+)
+      (throw 'handler-done nil)))
    (unless (probe-file path)
      ;; does not exist
      (setf (return-code) +http-not-found+)




More information about the Tbnl-devel mailing list