[hunchentoot-devel] url-encoding file names

Mathias Dahl mathias.dahl at gmail.com
Sun Jun 17 21:35:52 UTC 2007


> This question actually has nothing to do with Hunchentoot but with
> understanding what URL-encoding is.

I realized that after posting, URL-encoding is for encoding values
that otherwise has special meaning in URLs.

> And the spaces won't confuse Firefox.

That does not work for me. I cannot say if it is Firefox or Apache
that mess up. These two URLs are supposed to be interchangeable, but
only the latter works for me when I paste it in the address field of
Firefox:

http://myserver/somepath/Tommy+K%C3%B6rberg/Tommy+K%C3%B6rberg+-+Stad+i+ljus.mp3

http://myserver/somepath/Tommy%20K%C3%B6rberg/Tommy%20K%C3%B6rberg%20-%20Stad%20i%20ljus.mp3

The former gives me this:

====
Object not found!

The requested URL was not found on this server. If you entered the URL
manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.
Error 404
myserver
...
====

> What you probably want is (something similar) to this (untested):
>
>   (defun foo (pathspec)
>     (format nil "~{~A/~}~A"
>             (mapcar #'url-encode
>                     (rest (pathname-directory pathspec)))
>             (url-encode (file-namestring pathspec))))
>

Ah, yes it is, thanks! That is what I wondered if it existed in
Hunchentoot :). Maybe it could be an addition to Hunchentoot for your
next release, url-encode-path-parts or similar? With an optional
format parameter. Modulo my problem with "+" vs "%20", of course...

/Mathias



More information about the Tbnl-devel mailing list