Jump to content

unlink fails if filename has a quote


snowsquirrel

Recommended Posts

I am trying to unlink a file with this name "01 doug's dog.mp3", but unlink fails, saying it can't delete "01 doug". I tried calling addslashes on the string before passing it to unlink, but this didn't seem to help at all. I would think that I wouldn't have to escape the name at all. Does unlink make an external call to command like 'rm' or 'del'. I would have thought it would just call the unix system call 'unlink', which does not need to escape the name.

for example this c program runs fine:
[code]
#include <stdio.h>
#include <unistd.h>

int main()
{
  int rslt = unlink( "01 dougs's dog.mp3" );
  printf("results was %d\n", rslt);
  return rslt;
}
[/code]
yet my PHP fails:
[code]
unlink( "01 dougs's dog.mp3" );
[/code]

~S
Link to comment
Share on other sites

[!--quoteo(post=357647:date=Mar 23 2006, 01:16 PM:name=snowsquirrel)--][div class=\'quotetop\']QUOTE(snowsquirrel @ Mar 23 2006, 01:16 PM) [snapback]357647[/snapback][/div][div class=\'quotemain\'][!--quotec--] I tried calling addslashes on the string before passing it to unlink, but this didn't seem to help at all.
[/quote]
Yes.

Besides, I shouldn't need to escape it anyway, as I am not passed the string to an external command? I am just about convinced that this is a legitimate bug. Maybe tonight, I'll crack open the PHP source code.... yuck.

~S
Link to comment
Share on other sites

Sorry, must have missed that part in the origional post. I'd have to say it's probably a bug as well. For the longterm if they can't get a fix, I'd suggest modifying file names as they're put on the server.
Link to comment
Share on other sites

[!--quoteo(post=357694:date=Mar 23 2006, 03:07 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 23 2006, 03:07 PM) [snapback]357694[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I'd suggest modifying file names as they're put on the server.
[/quote]
I was afraid of that. ;-)

Thanks,

~S
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.