Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^6: Getting information about a remote file via SSH: how to escape the filename

by salva (Abbot)
on Jun 28, 2013 at 08:13 UTC ( #1041175=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Getting information about a remote file via SSH: how to escape the filename
in thread Getting information about a remote file via SSH: how to escape the filename

Suggestions on how to stay safe are very welcome

Avoid the shell as much as you can (i.e. using system $cmd, @args instead of system "$cms @args").

Otherwise, quote your data properly. For instance, for POSIX shells I use the following sub to quote commands and arguments:

my $glob_class = '*?\\[\\],{}:!^~'; sub quote { shift; my $quoted = join '', map { ( m|\A'\z| ? "\\'" : m|\A'| ? "\"$_\"" : m|\A[$noquote_class]+\z|o ? $_ : "'$_'" ) } split /('+)/, $_[0]; length $quoted ? $quoted : "''"; }


Comment on Re^6: Getting information about a remote file via SSH: how to escape the filename
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2015-07-05 20:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls