aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornatoponen <57988162+natoponen@users.noreply.github.com>2022-11-08 10:45:58 +0300
committerGitHub <noreply@github.com>2022-11-08 10:45:58 +0300
commitbd7a1e4dcb592ac35bd6756d7d2568c3ebce2b5a (patch)
tree104856c63fd6ec7f08b9a435f6f7be3ca17962ad /lib
parent0f3fdced4f214558fd3240bfaf868b661a8de8a2 (diff)
downloadnextcloud-server-bd7a1e4dcb592ac35bd6756d7d2568c3ebce2b5a.tar.gz
nextcloud-server-bd7a1e4dcb592ac35bd6756d7d2568c3ebce2b5a.zip
Appropriate length check in Notification.php
There is an issue(bug) when using UTF-8 symbols in any method, which checks the length of string as `isset($id[64])`. You can set only 32 UTF-8 symbols because they are 2 byte, and this "array" check seems inapropriate in this case, as it throws unexpected exceptions. Signed-off-by: natoponen <57988162+natoponen@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Notification/Notification.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php
index 3e5cf1d6934..add4029b616 100644
--- a/lib/private/Notification/Notification.php
+++ b/lib/private/Notification/Notification.php
@@ -197,12 +197,12 @@ class Notification implements INotification {
* @since 8.2.0 - 9.0.0: Type of $id changed to string
*/
public function setObject(string $type, string $id): INotification {
- if ($type === '' || isset($type[64])) {
+ if ($type === '' || mb_strlen($type) > 64) {
throw new \InvalidArgumentException('The given object type is invalid');
}
$this->objectType = $type;
- if ($id === '' || isset($id[64])) {
+ if ($id === '' || mb_strlen($id) > 64) {
throw new \InvalidArgumentException('The given object id is invalid');
}
$this->objectId = $id;