This commit is contained in:
2022-10-23 01:39:27 +02:00
parent 8c17aab483
commit 1929b84685
4130 changed files with 479334 additions and 0 deletions

57
vendor/winbox/args/src/Args.php vendored Executable file
View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of the Winbox packages.
*
* (c) John Stevenson <john-stevenson@blueyonder.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Winbox;
class Args
{
/**
* Escapes a string to be used as a shell argument
*
* Provides a more robust method on Windows than escapeshellarg.
*
* Feel free to copy this function, but please keep the following notice:
* MIT Licensed (c) John Stevenson <john-stevenson@blueyonder.co.uk>
* See https://github.com/johnstevenson/winbox-args for more information.
*
* @param string $arg The argument to be escaped
* @param bool $meta Additionally escape cmd.exe meta characters
*
* @return string The escaped argument
*/
public static function escape($arg, $meta = true)
{
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
return escapeshellarg($arg);
}
$quote = strpbrk($arg, " \t") !== false || $arg === '';
$arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
if ($meta) {
$meta = $dquotes || preg_match('/%[^%]+%/', $arg);
if (!$meta && !$quote) {
$quote = strpbrk($arg, '^&|<>()') !== false;
}
}
if ($quote) {
$arg = preg_replace('/(\\\\*)$/', '$1$1', $arg);
$arg = '"'.$arg.'"';
}
if ($meta) {
$arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
}
return $arg;
}
}