Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(dav): Allow array of array of scalars, and fix error message
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Oct 20, 2025
commit eeb1dc86a4682628bde735c16c438e0bc0c4f897
37 changes: 22 additions & 15 deletions apps/dav/lib/DAV/CustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,18 @@ private function formatPath(string $path): string {
return $path;
}

private static function checkIsArrayOfScalar(string $name, array $array): void {
foreach ($array as $item) {
if (is_array($item)) {
self::checkIsArrayOfScalar($name, $item);
} elseif ($item !== null && !is_scalar($item)) {
throw new DavException(
"Property \"$name\" has an invalid value of array containing " . gettype($item),
);
}
}
}

/**
* @throws ParseException If parsing a \Sabre\DAV\Xml\Property\Complex value fails
* @throws DavException If the property value is invalid
Expand Down Expand Up @@ -607,25 +619,20 @@ private function encodeValueForDatabase(string $path, string $name, mixed $value
} else {
if (is_array($value)) {
// For array only allow scalar values
foreach ($value as $item) {
if (!is_scalar($item)) {
throw new DavException(
"Property \"$name\" has an invalid value of array containing " . gettype($value),
);
}
}
self::checkIsArrayOfScalar($name, $value);
} elseif (!is_object($value)) {
throw new DavException(
"Property \"$name\" has an invalid value of type " . gettype($value),
);
}
if (!str_starts_with($value::class, 'Sabre\\DAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'Sabre\\CalDAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'Sabre\\CardDAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'OCA\\DAV\\')) {
throw new DavException(
"Property \"$name\" has an invalid value of class " . $value::class,
);
} else {
if (!str_starts_with($value::class, 'Sabre\\DAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'Sabre\\CalDAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'Sabre\\CardDAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'OCA\\DAV\\')) {
throw new DavException(
"Property \"$name\" has an invalid value of class " . $value::class,
);
}
}
$valueType = self::PROPERTY_TYPE_OBJECT;
// serialize produces null character
Expand Down
Loading