From f76e1afda029dad092e29575e17b4cf30041f3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Ivan=C4=8Di=C4=87?= Date: Thu, 26 Jan 2023 10:13:22 +0100 Subject: [PATCH] For user claims, substitute invalid utf8 chars with replacement char --- lib/Entity/UserEntity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Entity/UserEntity.php b/lib/Entity/UserEntity.php index 5f8c1be4..a5be3fff 100644 --- a/lib/Entity/UserEntity.php +++ b/lib/Entity/UserEntity.php @@ -68,7 +68,7 @@ public static function fromState(array $state): self $user = new self(); $user->identifier = $state['id']; - $user->claims = json_decode($state['claims'], true); + $user->claims = json_decode($state['claims'], true, 512, JSON_INVALID_UTF8_SUBSTITUTE); $user->updatedAt = TimestampGenerator::utc($state['updated_at']); $user->createdAt = TimestampGenerator::utc($state['created_at']); @@ -82,7 +82,7 @@ public function getState(): array { return [ 'id' => $this->getIdentifier(), - 'claims' => json_encode($this->getClaims()), + 'claims' => json_encode($this->getClaims(), JSON_INVALID_UTF8_SUBSTITUTE), 'updated_at' => $this->getUpdatedAt()->format('Y-m-d H:i:s'), 'created_at' => $this->getCreatedAt()->format('Y-m-d H:i:s'), ];