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

Timothy Ritchey tritchey at mac.com
Wed Nov 14 16:46:22 UTC 2007


This bug also exists in older versions of SBCL in case anyone has run  
into it. 0.9.12 is known to not work, but later versions (1.0.10 for  
example) do.

Cheers,
Tim

On Nov 14, 2007, at 11:08 AM, Hans Hübner wrote:

> 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)
> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel




More information about the Tbnl-devel mailing list