FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Spaces in filenames
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Spaces in filenames [message #173702 is a reply to message #173701] Sat, 30 April 2011 01:26 Go to previous messageGo to previous message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma:
Member
At Sat, 30 Apr 2011 00:00:50 +0100 Tim Streater <timstreater(at)waitrose(dot)com> wrote:

>
> When my app starts up, it discovers where it has been installed using:
>
> $instdir = dirname (__FILE__);
>
> Now, I have no control over where this might be in the file system, and
> the user may well put it somewhere such that the path contains spaces.
> I'm passing this round the app, and in the fullness of time may be doing
> things like:
>
> $fp = fopen ($instdir . "/wiggy", "r");
>
> Does it matter to PHP filesystem functions if the filename contains
> spaces?
>
> But what's worse, I'll also be passing $instdir to shell scripts via
> exec ().
>
> Seems to me I can:
>
> 1) search/replace $instdir to escape spaces with backslash-space. But
> does this mess up PHP filesystem functions?

Most likely.

>
> 2) leave $instdir as-is, but use escapeshellarg on it whenever I need to
> pass it through exec().

This is the approach.

OTOH, you really should not be using exec() at all -- it is a security
risk.

Note furthur: it is more likely that your PHP code will be installed on
a UNIX (Linux) system (eg a LAMP box) and Linux sysadmins (and many
users) tend to avoid spaces in file pathnames, esp. on servers. You may
be chasing a problem that is not going to be an issue.

>
> Which is the better approach?
>

--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP Runs In WinXP Command Window But Not In Browser
Next Topic: Html code beautifier
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 06:23:59 GMT 2024

Total time taken to generate the page: 0.04198 seconds