Skip to content

Commit

Permalink
Allow the escaping of & using &. Example: zs-client.php configura…
Browse files Browse the repository at this point in the history
…tionStoreDirectives --directives="error_reporting=E_ALL & ~E_NOTICE & ~E_USER_NOTICE"
  • Loading branch information
slav-at-attachix committed Jan 30, 2024
1 parent 2da7666 commit 0e414fe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/Client/src/Client/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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), '}');
Expand Down

0 comments on commit 0e414fe

Please sign in to comment.