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
Next Next 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 authored and backportbot[bot] committed Oct 20, 2025
commit e164506b2104a18145135bb0ffcae08548e44653
37 changes: 22 additions & 15 deletions apps/dav/lib/DAV/CustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,18 @@
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(

Check failure on line 423 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedClass

apps/dav/lib/DAV/CustomPropertiesBackend.php:423:15: UndefinedClass: Class, interface or enum named OCA\DAV\DAV\DavException does not exist (see https://psalm.dev/019)

Check failure on line 423 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidThrow

apps/dav/lib/DAV/CustomPropertiesBackend.php:423:5: InvalidThrow: Cannot throw OCA\DAV\DAV\DavException as it does not extend Exception or implement Throwable (see https://psalm.dev/133)

Check failure on line 423 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

Class, interface or enum named OCA\DAV\DAV\DavException does not exist (see https://psalm.dev/019)

Check failure on line 423 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

Cannot throw OCA\DAV\DAV\DavException as it does not extend Exception or implement Throwable (see https://psalm.dev/133)
"Property \"$name\" has an invalid value of array containing " . gettype($item),
);
}
}
}

/**
* @param mixed $value
* @return array
Expand All @@ -428,25 +440,20 @@
} 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);

Check failure on line 443 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedVariable

apps/dav/lib/DAV/CustomPropertiesBackend.php:443:32: UndefinedVariable: Cannot find referenced variable $name (see https://psalm.dev/024)

Check failure on line 443 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

Cannot find referenced variable $name (see https://psalm.dev/024)
} elseif (!is_object($value)) {
throw new DavException(

Check failure on line 445 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedClass

apps/dav/lib/DAV/CustomPropertiesBackend.php:445:15: UndefinedClass: Class, interface or enum named OCA\DAV\DAV\DavException does not exist (see https://psalm.dev/019)

Check failure on line 445 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

Class, interface or enum named OCA\DAV\DAV\DavException does not exist (see https://psalm.dev/019)
"Property \"$name\" has an invalid value of type " . gettype($value),

Check failure on line 446 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedVariable

apps/dav/lib/DAV/CustomPropertiesBackend.php:446:18: UndefinedVariable: Cannot find referenced variable $name (see https://psalm.dev/024)

Check failure on line 446 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

Cannot find referenced variable $name (see https://psalm.dev/024)
);
}
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(

Check failure on line 453 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedClass

apps/dav/lib/DAV/CustomPropertiesBackend.php:453:16: UndefinedClass: Class, interface or enum named OCA\DAV\DAV\DavException does not exist (see https://psalm.dev/019)

Check failure on line 453 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

Class, interface or enum named OCA\DAV\DAV\DavException does not exist (see https://psalm.dev/019)
"Property \"$name\" has an invalid value of class " . $value::class,

Check failure on line 454 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedVariable

apps/dav/lib/DAV/CustomPropertiesBackend.php:454:19: UndefinedVariable: Cannot find referenced variable $name (see https://psalm.dev/024)

Check failure on line 454 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

Cannot find referenced variable $name (see https://psalm.dev/024)
);
}
}
$valueType = self::PROPERTY_TYPE_OBJECT;
$value = serialize($value);
Expand All @@ -457,7 +464,7 @@
/**
* @return mixed|Complex|string
*/
private function decodeValueFromDatabase(string $value, int $valueType): mixed {

Check failure on line 467 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

ReservedWord

apps/dav/lib/DAV/CustomPropertiesBackend.php:467:75: ReservedWord: mixed is a reserved word (see https://psalm.dev/095)

Check failure on line 467 in apps/dav/lib/DAV/CustomPropertiesBackend.php

View workflow job for this annotation

GitHub Actions / Psalm

mixed is a reserved word (see https://psalm.dev/095)
switch ($valueType) {
case self::PROPERTY_TYPE_XML:
return new Complex($value);
Expand Down
Loading