@cryptotaxi247 / kubo / commits / 761392d8d

commands/cli: Only allow recursive paths if -r option definition is OptionRecursivePath

Matt Bell committed Nov 19, 2014 at 00:26 UTC 761392d8de32d93410b5827c14dde5acbd3913bf
1 file changed +10 -3
commands/cli/parse.go
+10 -3
@@ -46,10 +46,17 @@ func Parse(input []string, stdin *os.File, root *cmds.Command) (cmds.Request, *c
46 return nil, cmd, path, err
47 }
48
49 - recursive, _, err := req.Option(cmds.RecShort).Bool()
50 - if err != nil {
51 - return nil, nil, nil, u.ErrCast()
49 + // if -r is provided, and it is associated with the package builtin
50 + // recursive path option, allow recursive file paths
51 + recursiveOpt := req.Option(cmds.RecShort)
52 + recursive := false
53 + if recursiveOpt != nil && recursiveOpt.Definition() == cmds.OptionRecursivePath {
54 + recursive, _, err = recursiveOpt.Bool()
55 + if err != nil {
56 + return nil, nil, nil, u.ErrCast()
57 + }
58 }
59 +
60 stringArgs, fileArgs, err := parseArgs(stringVals, stdin, cmd.Arguments, recursive)
61 if err != nil {
62 return nil, cmd, path, err