Skip to content

Commit bd7a1e4

Browse files
authored
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>
1 parent 0f3fdce commit bd7a1e4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/private/Notification/Notification.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ public function getDateTime(): \DateTime {
197197
* @since 8.2.0 - 9.0.0: Type of $id changed to string
198198
*/
199199
public function setObject(string $type, string $id): INotification {
200-
if ($type === '' || isset($type[64])) {
200+
if ($type === '' || mb_strlen($type) > 64) {
201201
throw new \InvalidArgumentException('The given object type is invalid');
202202
}
203203
$this->objectType = $type;
204204

205-
if ($id === '' || isset($id[64])) {
205+
if ($id === '' || mb_strlen($id) > 64) {
206206
throw new \InvalidArgumentException('The given object id is invalid');
207207
}
208208
$this->objectId = $id;

0 commit comments

Comments
 (0)