Skip to content

Commit 1a0b220

Browse files
committed
fix(dav): Allow arrays (of scalars) in property values
Signed-off-by: Côme Chilliet <[email protected]>
1 parent 0283fbc commit 1a0b220

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

apps/dav/lib/DAV/CustomPropertiesBackend.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,16 @@ private function encodeValueForDatabase(string $path, string $name, mixed $value
600600
$valueType = self::PROPERTY_TYPE_HREF;
601601
$value = $value->getHref();
602602
} else {
603-
if (!is_object($value)) {
603+
if (is_array($value)) {
604+
// 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+
}
612+
} elseif (!is_object($value)) {
604613
throw new DavException(
605614
"Property \"$name\" has an invalid value of type " . gettype($value),
606615
);
@@ -631,6 +640,10 @@ private function decodeValueFromDatabase(string $value, int $valueType): mixed {
631640
case self::PROPERTY_TYPE_HREF:
632641
return new Href($value);
633642
case self::PROPERTY_TYPE_OBJECT:
643+
if (preg_match('/^a:/', $value)) {
644+
// Array, unserialize only scalar values
645+
return unserialize(str_replace('\x00', chr(0), $value), ['allowed_classes' => false]);
646+
}
634647
if (!preg_match('/^O\:\d+\:\"(OCA\\\\DAV\\\\|Sabre\\\\(Cal|Card)?DAV\\\\Xml\\\\Property\\\\)/', $value)) {
635648
throw new \LogicException('Found an object class serialized in DB that is not allowed');
636649
}

0 commit comments

Comments
 (0)