>>>>> On Fri, 20 Feb 2004 10:09:28 +0000, David Johnson-Davies
>>>>> <david@xxxxxxxxxxxxxxx> said:
David> Can anyone help?
David> I am exporting a directory of GIF images with:
David> (export-url "/gifs/" :directory "recursive-p t)
David> so I can link to them in Web pages. However, some of the filenames
contain
David> spaces, eg "my font.gif", and it doesn't seem to work whether I put:
David> <a href="http://www.mysite.com/my%20font.gif">Link</a>
David> or:
David> <a href="http://www.mysite.com/my font.gif">Link</a>
David> Is there some way I can turn on escaping of filenames on export, or do
I
David> need to do this by hand somehow?
Looks like a bug in CL-HTTP's url interning. The browser always sends
"my%20font.gif" but the URL entries created for recursive exports contain the
spaced version "my font.gif". This happens because URL::%UNESCAPE-URL (called
from URL:CANONICALIZE-URL and URL::%CANONICALIZE-HOST-PREFIXED-URL) only
removes "safe" escapes like %41, but leaves %20 etc.
Does it work if you define URL::%UNESCAPE-URL like this (and recompile the
rest of url.lisp because it is inlined)?
(defun %unescape-url (url-string start end destructive-p)
(declare (fixnum start end)
(values canonical-url new-start new-end))
(cond (*escape-urls*
(http::with-bad-escaping-resignalled (url-string :start start :end end
:reason "Bad
Escaping: Ill-escaped URL")
(cond (destructive-p
(multiple-value-bind (unescaped-string new-end)
(http::nstring-unescape-special-chars url-string start
end t #\space)
(values unescaped-string start new-end)))
(t (multiple-value-bind (unescaped-string chars-unescaped-p
new-url-string-p)
(string-unescape-special-chars url-string start end)
(declare (ignore chars-unescaped-p))
(unless new-url-string-p
(setq unescaped-string (subseq url-string start end)))
(values unescaped-string 0 (length unescaped-string)))))))
(destructive-p
(values url-string start end))
(t (values (subseq url-string start end) (- end start)))))
__Martin
|