Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Simple Path Cleanup

by sgifford (Prior)
on May 11, 2009 at 03:57 UTC ( #763180=note: print w/ replies, xml ) Need Help??

in reply to Simple Path Cleanup

What you will need to do to avoid an unsafe file or path name will depend on what sorts of file names you are expecting, and what areas you consider safe. If your filenames are simple, just requiring that they match ^\w+$ should be OK. If they can contain more characters than that, you will need something more complicated, but the basic things are to exclude / and make sure your filename isn't all dots.

That's likely to be easier than trying to safely open a pathname and then make sure it is safe.

Also, consider using taint mode in your script. That would require you to sanitize filenames before opening them, halting your program if you forgot. It's a good safety net for any program manipulating the filesystem on behalf of Internet users.

Hope this helps! by assuming the directory is safe and then figuring out where you really are in the filesystem to make sure it's not what you expect.

Comment on Re: Simple Path Cleanup
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://763180]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2016-02-12 00:37 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (386 votes), past polls