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 5452b73747098a5f4d05cdee2d679093bcf04823
37 changes: 22 additions & 15 deletions apps/dav/lib/DAV/CustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,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 443 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:443:15: UndefinedClass: Class, interface or enum named OCA\DAV\DAV\DavException does not exist (see https://psalm.dev/019)

Check failure on line 443 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:443:5: InvalidThrow: 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 @@ -443,30 +455,25 @@
if (is_scalar($value)) {
$valueType = self::PROPERTY_TYPE_STRING;
} elseif ($value instanceof Complex) {
$valueType = self::PROPERTY_TYPE_XML;
$value = $value->getXml();
} 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 463 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:463:32: UndefinedVariable: Cannot find referenced variable $name (see https://psalm.dev/024)
} elseif (!is_object($value)) {
throw new DavException(

Check failure on line 465 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:465:15: UndefinedClass: 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 466 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:466:18: UndefinedVariable: 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 473 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:473:16: UndefinedClass: 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 474 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:474:19: UndefinedVariable: Cannot find referenced variable $name (see https://psalm.dev/024)
);
}
}
$valueType = self::PROPERTY_TYPE_OBJECT;
// serialize produces null character
Expand Down
Loading