From 89cfc7c2a538dd0361bd46b3d7b55f5c67c8fe43 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 12 Sep 2024 10:38:46 +0200 Subject: [PATCH] fix(LDAP): check index before accessing it Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/Access.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 931da3014003c..31f88c4bf0b36 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -312,20 +312,19 @@ public function extractAttributeValuesFromResult($result, $attribute) { * @return array If a range was detected with keys 'values', 'attributeName', * 'attributeFull' and 'rangeHigh', otherwise empty. */ - public function extractRangeData($result, $attribute) { + public function extractRangeData(array $result, string $attribute): array { $keys = array_keys($result); foreach ($keys as $key) { if ($key !== $attribute && str_starts_with((string)$key, $attribute)) { $queryData = explode(';', (string)$key); - if (str_starts_with($queryData[1], 'range=')) { + if (isset($queryData[1]) && str_starts_with($queryData[1], 'range=')) { $high = substr($queryData[1], 1 + strpos($queryData[1], '-')); - $data = [ + return [ 'values' => $result[$key], 'attributeName' => $queryData[0], 'attributeFull' => $key, 'rangeHigh' => $high, ]; - return $data; } } }