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

19
vendor/winbox/args/LICENSE vendored Executable file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2016 John Stevenson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

50
vendor/winbox/args/README.md vendored Executable file
View File

@@ -0,0 +1,50 @@
Winbox-Args
===========
[![Build Status](https://travis-ci.org/johnstevenson/winbox-args.svg?branch=master)](https://travis-ci.org/johnstevenson/winbox-args)
[![Build status](https://ci.appveyor.com/api/projects/status/p4k75qqcyioj0mfl?svg=true)](https://ci.appveyor.com/project/johnstevenson/winbox-args)
A PHP function to escape command-line arguments, which on Windows replaces `escapeshellarg` with a more robust method. Install from [Packagist][packagist] and use it like this:
```php
$escaped = Winbox\Args::escape($argument);
```
Alternatively, you can just [copy the code][function] into your own project (but please keep the license attribution and documentation link).
### What it does
The following transformations are made:
* Double-quotes are escaped with a backslash, with any preceeding backslashes doubled up.
* The argument is only enclosed in double-quotes if it contains whitespace or is empty.
* Trailing backslashes are doubled up if the argument is enclosed in double-quotes.
See [How Windows parses the command-line](https://github.com/johnstevenson/winbox-args/wiki/How-Windows-parses-the-command-line) if you would like to know why.
By default, _cmd.exe_ meta characters are also escaped:
* by caret-escaping the transformed argument (if it contains internal double-quotes or `%...%` syntax).
* or by enclosing the argument in double-quotes.
There are a couple limitations:
1. If _cmd_ is started with _DelayedExpansion_ enabled, `!...!` syntax could expand environment variables.
2. If the program name requires caret-escaping and contains whitespace, _cmd_ will not recognize it.
See [How cmd.exe parses a command](https://github.com/johnstevenson/winbox-args/wiki/How-cmd.exe-parses-a-command) and [Implementing a solution](https://github.com/johnstevenson/winbox-args/wiki/Implementing-a-solution) for more information.
### Is that it?
Yup. An entire repo for a tiny function. However, it needs quite a lot of explanation because:
* the command-line parsing rules in Windows are not immediately obvious.
* PHP generally uses _cmd.exe_ to execute programs and this applies a different set of rules.
* there is no simple solution.
Full details explaining the different parsing rules, potential pitfalls and limitations can be found in the [Wiki][wiki].
## License
Winbox-Args is licensed under the MIT License - see the LICENSE file for details.
[function]: https://github.com/johnstevenson/winbox-args/blob/master/src/Args.php#L15
[wiki]:https://github.com/johnstevenson/winbox-args/wiki/Home
[packagist]: https://packagist.org/packages/winbox/args

22
vendor/winbox/args/appveyor.yml vendored Executable file
View File

@@ -0,0 +1,22 @@
build: false
shallow_clone: false
platform: 'x86'
clone_folder: C:\projects\winbox-args
init:
- cinst php
- SET PATH=C:\tools\php\;%PATH%
install:
- cd c:\tools\php
- copy php.ini-production php.ini
- echo date.timezone="UTC" >> php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo extension=php_intl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- echo extension=php_fileinfo.dll >> php.ini
- cd C:\projects\winbox-args
- php -r "readfile('https://getcomposer.org/installer');" | php
- php composer.phar require phpunit/phpunit:4.* --prefer-dist --dev --no-interaction
test_script:
- cd C:\projects\winbox-args
- vendor\bin\phpunit.bat

22
vendor/winbox/args/composer.json vendored Executable file
View File

@@ -0,0 +1,22 @@
{
"name": "winbox/args",
"description": "Windows command-line formatter",
"keywords": ["windows", "escape", "command"],
"homepage": "http://github.com/johnstevenson/winbox-args",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "John Stevenson",
"email": "john-stevenson@blueyonder.co.uk"
}
],
"require": {
"php": ">=5.3.3"
},
"autoload": {
"psr-4": {
"Winbox\\": "src/"
}
}
}

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;
}
}