File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import (
2929// properly handled.
3030//
3131// These metacharacters include: | & ; ( ) < > \t \n $ \ `
32- const shellMetachars = "|&;()<> \t \n $\\ `"
32+ const shellMetachars = "|&;()<> \t \n $\\ `' \" "
3333
3434// metacharRegex matches any shell metacharcter.
3535var metacharRegex = regexp .MustCompile (`([` + regexp .QuoteMeta (shellMetachars ) + `])` )
@@ -54,11 +54,10 @@ func (r syscallExec) String() string {
5454 return "exec"
5555}
5656
57- // Escape1 escapes shell metacharacters in a single command-line argument.
58- func Escape1 (arg string ) string {
57+ // escapeArg escapes shell metacharacters in a single command-line argument.
58+ func escapeArg (arg string ) string {
5959 if strings .ContainsAny (arg , shellMetachars ) {
60- e := metacharRegex .ReplaceAllString (arg , `\$1` )
61- return fmt .Sprintf (`"%s"` , e )
60+ return metacharRegex .ReplaceAllString (arg , `\$1` )
6261 }
6362 return arg
6463}
@@ -68,7 +67,7 @@ func Escape1(arg string) string {
6867func Escape (args []string ) []string {
6968 escaped := make ([]string , len (args ))
7069 for i := range args {
71- escaped [i ] = Escape1 (args [i ])
70+ escaped [i ] = escapeArg (args [i ])
7271 }
7372 return escaped
7473}
Original file line number Diff line number Diff line change 11/*
2- # Copyright (c) 2021 , NVIDIA CORPORATION. All rights reserved.
2+ # Copyright (c) 2025 , NVIDIA CORPORATION. All rights reserved.
33#
44# Licensed under the Apache License, Version 2.0 (the "License");
55# you may not use this file except in compliance with the License.
You can’t perform that action at this time.
0 commit comments