[hunchentoot-devel] Workaround for OpenMCL bug in ENOUGH-NAMESTRING

Hans Hübner hans at huebner.org
Wed Nov 14 16:08:54 UTC 2007


Hi,

OpenMCL has a bug in ENOUGH-NAMESTRING that makes Hunchentoot fail
when the "/" prefix is exported from the file system using
CREATE-FOLDER-DISPATCHER-AND-HANDLER.  ENOUGH-NAMESTRING fails to work
for URI paths having more than one component.  As URI strings are not
path names, I find using ENOUGH-NAMESTRING being a little fishy here
anyway and I'd propose the following patch, courtesy of Kilian
Sprotte:

Index: misc.lisp
===================================================================
--- misc.lisp   (revision 2274)
+++ misc.lisp   (working copy)
@@ -177,6 +177,11 @@
       (lambda ()
         (handle-static-file path content-type)))))

+(defun enough-url (url url-prefix)
+  "Return the relative portion of URL relative to URL-PREFIX, similar
+to what enough-pathname does for path names."
+  (subseq url (mismatch url url-prefix)))
+
 (defun create-folder-dispatcher-and-handler (uri-prefix base-path &optional con
tent-type)
   "Creates and returns a dispatch function which will dispatch to a
 handler function which emits the file relative to BASE-PATH that is
@@ -193,8 +198,8 @@
     (error "~S is supposed to denote a directory." base-path))
   (flet ((handler ()
            (let* ((script-name (url-decode (script-name)))
-                  (script-path (enough-namestring (regex-replace-all "\\\\" scr
ipt-name "/")
-                                                  uri-prefix))
+                  (script-path (enough-url (regex-replace-all "\\\\" script-nam
e "/")
+                                           uri-prefix))
                   (script-path-directory (pathname-directory script-path)))
              (unless (or (stringp script-path-directory)
                          (null script-path-directory)



More information about the Tbnl-devel mailing list