mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 16:14:40 +00:00
(configd) support optional parameters
This commit is contained in:
parent
39d99e60ed
commit
1db1afb212
@ -411,6 +411,13 @@ class Action(object):
|
||||
if script_command.find('%s') > -1:
|
||||
# use command execution parameters in action parameter template
|
||||
# use quotes on parameters to prevent code injection
|
||||
if script_command.count('%s') > len(parameters):
|
||||
# script command accepts more parameters then given, full with empty parameters
|
||||
for i in range(script_command.count('%s')-len(parameters)):
|
||||
parameters.append("")
|
||||
elif len(parameters) > script_command.count('%s'):
|
||||
# parameters then expected, fail execution
|
||||
return 'Parameter mismatch'
|
||||
script_command = script_command % tuple(map(lambda x: '"'+x.replace('"', '\\"')+'"',
|
||||
parameters[0:script_command.count('%s')]))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user