Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

uri and file names

by rsiedl (Friar)
on Apr 03, 2007 at 05:19 UTC ( [id://607974]=perlquestion: print w/replies, xml ) Need Help??

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".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://607974]
Approved by monkfan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2026-02-14 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.