Skip to content

Commit 80121df

Browse files
committed
fix(dav): Allow array of array of scalars, and fix error message
Signed-off-by: Côme Chilliet <[email protected]>
1 parent 1a0b220 commit 80121df

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

apps/dav/lib/DAV/CustomPropertiesBackend.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,18 @@ private function formatPath(string $path): string {
566566
return $path;
567567
}
568568

569+
private static function checkIsArrayOfScalar(string $name, array $array): void {
570+
foreach ($array as $item) {
571+
if (is_array($item)) {
572+
self::checkIsArrayOfScalar($name, $array);
573+
} elseif ($item !== null && !is_scalar($item)) {
574+
throw new DavException(
575+
"Property \"$name\" has an invalid value of array containing " . gettype($item),
576+
);
577+
}
578+
}
579+
}
580+
569581
/**
570582
* @throws ParseException If parsing a \Sabre\DAV\Xml\Property\Complex value fails
571583
* @throws DavException If the property value is invalid
@@ -602,13 +614,7 @@ private function encodeValueForDatabase(string $path, string $name, mixed $value
602614
} else {
603615
if (is_array($value)) {
604616
// For array only allow scalar values
605-
foreach ($value as $item) {
606-
if (!is_scalar($item)) {
607-
throw new DavException(
608-
"Property \"$name\" has an invalid value of array containing " . gettype($value),
609-
);
610-
}
611-
}
617+
self::checkIsArrayOfScalar($name, $value);
612618
} elseif (!is_object($value)) {
613619
throw new DavException(
614620
"Property \"$name\" has an invalid value of type " . gettype($value),

0 commit comments

Comments
 (0)