From 0e414feb7b099645bf731d958933e5051d61db41 Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Tue, 30 Jan 2024 14:15:01 +0100 Subject: [PATCH] Allow the escaping of & using &. Example: zs-client.php configurationStoreDirectives --directives="error_reporting=E_ALL & ~E_NOTICE & ~E_USER_NOTICE" --- module/Client/src/Client/Utils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/Client/src/Client/Utils.php b/module/Client/src/Client/Utils.php index d51e996..d33c9fa 100644 --- a/module/Client/src/Client/Utils.php +++ b/module/Client/src/Client/Utils.php @@ -16,10 +16,11 @@ abstract class Utils public static function parseString($string, &$data, $delimiter = '&') { // check if the values are provided like a query string + $string = str_replace('&', chr(0x7f) . chr(0xff) . chr(0x7f), $string); // escaped ampersand $pairs = explode($delimiter, $string); foreach ($pairs as $pair) { list($k, $v) = explode('=', $pair); - + $v = str_replace(chr(0x7f) . chr(0xff) . chr(0x7f), '&', $v); // replace escaped ampersand if (preg_match("/^(.*?)((\[(.*?)\])+)$/m", $k, $m)) { $parts = explode('][', rtrim(ltrim($m[2], '['), ']')); $json = '{"'.implode('":{"', $parts).'": '.json_encode($v).str_pad('', count($parts), '}');