rsiedl has asked for the wisdom of the Perl Monks concerning the following question:

hi monks

i have some files on my linux system that contain uri_escaped characters.
i.e. boo%20hoo.xls
i would like to be able to link to/download these files via a web browser. however when i try a normal href it translates the uri_escaped chars back into their normal values (%20 becomes "space", etc) and then says the file cannot be found.
does anyone have any suggestions on how to work around this?

Replies are listed 'Best First'.
Re: uri and file names
by Anno (Deacon) on Apr 03, 2007 at 06:02 UTC
    Use URI::Escape to escape the filenames. "boo%20hoo.xls" becomes "boo%2520hoo.xls".

    Anno

    Update: Pointer to URI::Escape added.

Re: uri and file names
by ferreira (Chaplain) on Apr 03, 2007 at 18:35 UTC

    Anno's solution is just what you need. URI-escaping is used at URI's to reduce the character set a browser needs to understand as input and reduce interpretation problems (with spaces and special characters). Then "boo%20hoo.xls" would generally bring it up a resource with a name like "boo hoo.xls". But if your files have been named after URI-escaping, you need to repeat the process because "%" is special now. That's why you need to URI::Escape again.

    That reminded me of an article by Robert Spier (A Canary Trap for URI Escaping) on how they handled the problem of multiply-escaped URIs for the Bitcard sign-on system with the help of "canary traps".