mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Fix nested escaping
This commit is contained in:
parent
c74e5dcb1a
commit
991c6dea64
1 changed files with 21 additions and 7 deletions
|
|
@ -291,13 +291,7 @@ class Resolvers
|
|||
return;
|
||||
}
|
||||
|
||||
foreach ($payload as $key => $value) {
|
||||
if (\str_starts_with($key, '$')) {
|
||||
$escapedKey = \str_replace('$', '_', $key);
|
||||
$payload[$escapedKey] = $value;
|
||||
unset($payload[$key]);
|
||||
}
|
||||
}
|
||||
$payload = self::escapePayload($payload, 1);
|
||||
|
||||
if ($beforeResolve) {
|
||||
$payload = $beforeResolve($payload);
|
||||
|
|
@ -305,4 +299,24 @@ class Resolvers
|
|||
|
||||
$resolve($payload);
|
||||
}
|
||||
|
||||
private static function escapePayload(array $payload, int $depth) {
|
||||
if($depth > App::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($payload as $key => $value) {
|
||||
if (\str_starts_with($key, '$')) {
|
||||
$escapedKey = \str_replace('$', '_', $key);
|
||||
$payload[$escapedKey] = $value;
|
||||
unset($payload[$key]);
|
||||
}
|
||||
|
||||
if(\is_array($value)) {
|
||||
$payload[$key] = self::escapePayload($value, $depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue