#25 Correctly quote filenames in commands

closed
nobody
None
5
2008-06-05
2007-10-23
No

When command lines are constructed, filenames are often quoted by simply adding double quotes. This won't work if the filename contains certain shell metacharacters, including $, ` (backtick) or " (double quote).

The attached patch adds and uses a quote() function, which quotes a filename (or any other string) by enclosing it in single quotes and replacing any embedded single quotes with the string '\'' (single-quote, backslash, single-quote, single-quote).

This should ensure that, after the shell has performed its substitutions, you end up with the original string.

Discussion

  • Glynn Clements

    Glynn Clements - 2007-10-23

    Patch to correctly quote filenames in commands

     
  • Roland Baudin

    Roland Baudin - 2007-10-31

    Logged In: YES
    user_id=629537
    Originator: NO

    Hi,
    many thanks for this patch. I'll look to it and add it if necessary...
    Best regards,
    RB

     
  • Roland Baudin

    Roland Baudin - 2008-06-05
    • status: open --> closed
     
  • Roland Baudin

    Roland Baudin - 2008-06-05

    Logged In: YES
    user_id=629537
    Originator: NO

    Hi,
    I've added your patch to Xfe version 1.18.
    Thanks for the patch,
    RB

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks