mirror of
https://github.com/nextcloud/server.git
synced 2026-05-25 02:34:12 -04:00
fix(dav): Allow arrays (of scalars) in property values
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
50ae7e4139
commit
5aaef3aa53
1 changed files with 14 additions and 1 deletions
|
|
@ -446,7 +446,16 @@ class CustomPropertiesBackend implements BackendInterface {
|
|||
$valueType = self::PROPERTY_TYPE_XML;
|
||||
$value = $value->getXml();
|
||||
} else {
|
||||
if (!is_object($value)) {
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
} elseif (!is_object($value)) {
|
||||
throw new DavException(
|
||||
"Property \"$name\" has an invalid value of type " . gettype($value),
|
||||
);
|
||||
|
|
@ -475,6 +484,10 @@ class CustomPropertiesBackend implements BackendInterface {
|
|||
case self::PROPERTY_TYPE_XML:
|
||||
return new Complex($value);
|
||||
case self::PROPERTY_TYPE_OBJECT:
|
||||
if (preg_match('/^a:/', $value)) {
|
||||
// Array, unserialize only scalar values
|
||||
return unserialize(str_replace('\x00', chr(0), $value), ['allowed_classes' => false]);
|
||||
}
|
||||
if (!preg_match('/^O\:\d+\:\"(OCA\\\\DAV\\\\|Sabre\\\\(Cal|Card)?DAV\\\\Xml\\\\Property\\\\)/', $value)) {
|
||||
throw new \LogicException('Found an object class serialized in DB that is not allowed');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue