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)
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@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
Hi Hans,
On Wed, 14 Nov 2007 17:08:54 +0100, "Hans Hübner" hans@huebner.org wrote:
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:
Thanks. I've released a new version which incorporates your patch. Untested, as I'm currently in the process of re-installing my OS and my Lisps on my laptop.
The next time please send the patch as a an attachment or use a mail client which doesn't break lines willy-nilly... :)
Cheers, Edi.
On Nov 15, 2007 8:36 AM, Edi Weitz edi@agharta.de wrote:
Thanks. I've released a new version which incorporates your patch. Untested, as I'm currently in the process of re-installing my OS and my Lisps on my laptop.
Thanks! I talk all the blame should this fail for anyone.
The next time please send the patch as a an attachment or use a mail client which doesn't break lines willy-nilly... :)
Will do. I was unsure whether the list accepts attachments, but as it is for patches, it´d propably be stupid to be unsure about that.
-Hans
On Thu, 15 Nov 2007 08:38:54 +0100, "Hans Hübner" hans@huebner.org wrote:
I was unsure whether the list accepts attachments, but as it is for patches, it´d propably be stupid to be unsure about that.
It lets attachments go through up to a certain size and for larger attachments I (as the list admin) can decide on a case-by-case basis.