-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Winbox-Args contains a single function that escapes command-line arguments. On non-Windows platforms it calls the PHP escapeshellarg
function, but on Windows it uses a more robust method.
This is because escapeshellarg on Windows takes a simple approach that will probably work out okay: it wraps everything in double-quotes and replaces characters that might confuse things (double-quotes, percent signs and exclamation marks) with a space. If something breaks then you have to provide your own solution.
This is actually a non-trivial problem because the command you want to execute is usually passed through cmd.exe
. And the rules it uses to create a command-line differ slightly from the rules which the new process uses to parse out the arguments.
The following topics step through the factors that lead to this solution: