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

Re: How to escape single quote(s) without the use of quotemeta

by Anonymous Monk
on Apr 05, 2019 at 18:52 UTC ( #1232206=note: print w/replies, xml ) Need Help??


in reply to How to escape single quote(s) without the use of quotemeta

I have written a small script to convert mp4 to mp3 files and I am getting stuck when files contain single quote.

You seem to be constructing command line strings and feeding them to a shell. This is complicated and best handled by already written modules, such as String::ShellQuote. Note that if you do it incorrectly, your program faces the danger of a shell injection.

If you use list form of system (e.g. system "ffmpeg", "-loglevel", "warning", "-i", $infile, "-vn", "-aq", 5, "-acodec", "libvorbis", $outfile instead of system "ffmpeg -loglevel warning -i ".quote($infile)." -vn -aq 5 -acodec libvorbis ".quote($outfile), no shell sits between your script and the music encoding process and the risk of shell injection is averted.

Replies are listed 'Best First'.
Re^2: How to escape single quote(s) without the use of quotemeta
by Anonymous Monk on Apr 05, 2019 at 19:48 UTC
    You seem to be constructing command line strings and feeding them to a shell.

    really?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2021-06-21 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (98 votes). Check out past polls.

    Notices?