tests: fix shell quoting on native Windows Perl

Cherry-picked from #14949
Closes #15105
This commit is contained in:
Viktor Szakats 2024-09-20 15:10:42 +02:00
parent 9c1ab7fa4a
commit f88fb1c83e
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View File

@ -211,10 +211,15 @@ sub runclientoutput {
#
sub shell_quote {
my ($s)=@_;
if($s !~ m/^[-+=.,_\/:a-zA-Z0-9]+$/) {
# string contains a "dangerous" character--quote it
$s =~ s/'/'"'"'/g;
$s = "'" . $s . "'";
if($^O eq 'MSWin32') {
$s = '"' . $s . '"';
}
else {
if($s !~ m/^[-+=.,_\/:a-zA-Z0-9]+$/) {
# string contains a "dangerous" character--quote it
$s =~ s/'/'"'"'/g;
$s = "'" . $s . "'";
}
}
return $s;
}