From 7729f4c447184d846f91a444b12cb2633aae7268 Mon Sep 17 00:00:00 2001 From: Martijn Boers <2955898+martijnboers@users.noreply.github.com> Date: Wed, 22 Feb 2023 23:09:11 +0100 Subject: [PATCH] Validate that diff is a string before passing to mb_convert_encoding (#156) --- .../Doctrine/Auditing/Transaction/TransactionProcessor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Provider/Doctrine/Auditing/Transaction/TransactionProcessor.php b/src/Provider/Doctrine/Auditing/Transaction/TransactionProcessor.php index 515c1f5a..e3dc75e0 100644 --- a/src/Provider/Doctrine/Auditing/Transaction/TransactionProcessor.php +++ b/src/Provider/Doctrine/Auditing/Transaction/TransactionProcessor.php @@ -211,6 +211,7 @@ private function audit(array $data): void $schema = $data['schema'] ? $data['schema'].'.' : ''; $auditTable = $schema.$configuration->getTablePrefix().$data['table'].$configuration->getTableSuffix(); $dt = new DateTimeImmutable('now', new DateTimeZone($this->provider->getAuditor()->getConfiguration()->getTimezone())); + $diff = is_string($data["diff"]) ? mb_convert_encoding($data['diff'], 'UTF-8', 'UTF-8') : $data["diff"]; $payload = [ 'entity' => $data['entity'], @@ -219,7 +220,7 @@ private function audit(array $data): void 'object_id' => (string) $data['id'], 'discriminator' => $data['discriminator'], 'transaction_hash' => (string) $data['transaction_hash'], - 'diffs' => json_encode(mb_convert_encoding($data['diff'], 'UTF-8', 'UTF-8'), JSON_THROW_ON_ERROR), + 'diffs' => json_encode($diff, JSON_THROW_ON_ERROR), 'blame_id' => $data['blame']['user_id'], 'blame_user' => $data['blame']['username'], 'blame_user_fqdn' => $data['blame']['user_fqdn'],