note 125807 added to function.escapeshellarg
| From: | Anonymous@php.net | Date: | Thu, 11 Feb 2021 13:44:43 +0000 |
| Subject: | note 125807 added to function.escapeshellarg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219122@lists.php.net to get a copy of this message | ||
if you need to generate Linux arguments even when running on Windows, try
<?php
/**
* quote arguments using linux escape rules, regardless of host OS
* (eg, it will use linux escape rules even when running on Windows)
*
* @param string $arg
* @throws \InvalidArgumentException if argument contains null bytes
* @return string
*/
/*public static*/ function linux_escapeshellarg(string $arg): string
{
if (false !== strpos($arg, "\x00")) {
throw new \InvalidArgumentException("argument contains null bytes, it's
impossible to escape null bytes!");
}
return "'" . strtr($arg, [
"'" => "'\\''"
]) . "'";
}
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.166 (proxied: 80.203.132.70)
----
Manual Page -- http://php.net/manual/en/function.escapeshellarg.php
Edit -- https://master.php.net/note/edit/125807
Del: integrated -- https://master.php.net/note/delete/125807/integrated
Del: useless -- https://master.php.net/note/delete/125807/useless
Del: bad code -- https://master.php.net/note/delete/125807/bad+code
Del: spam -- https://master.php.net/note/delete/125807/spam
Del: non-english -- https://master.php.net/note/delete/125807/non-english
Del: in docs -- https://master.php.net/note/delete/125807/in+docs
Del: other reasons-- https://master.php.net/note/delete/125807
Reject -- https://master.php.net/note/reject/125807
Search -- https://master.php.net/manage/user-notes.php