@@ -426,7 +426,16 @@ private function encodeValueForDatabase($value): array {
426426 $ valueType = self ::PROPERTY_TYPE_XML ;
427427 $ value = $ value ->getXml ();
428428 } else {
429- if (!is_object ($ value )) {
429+ if (is_array ($ value )) {
430+ // For array only allow scalar values
431+ foreach ($ value as $ item ) {
432+ if (!is_scalar ($ item )) {
433+ throw new DavException (
434+ "Property \"$ name \" has an invalid value of array containing " . gettype ($ value ),
435+ );
436+ }
437+ }
438+ } elseif (!is_object ($ value )) {
430439 throw new DavException (
431440 "Property \"$ name \" has an invalid value of type " . gettype ($ value ),
432441 );
@@ -453,6 +462,10 @@ private function decodeValueFromDatabase(string $value, int $valueType): mixed {
453462 case self ::PROPERTY_TYPE_XML :
454463 return new Complex ($ value );
455464 case self ::PROPERTY_TYPE_OBJECT :
465+ if (preg_match ('/^a:/ ' , $ value )) {
466+ // Array, unserialize only scalar values
467+ return unserialize (str_replace ('\x00 ' , chr (0 ), $ value ), ['allowed_classes ' => false ]);
468+ }
456469 if (!preg_match ('/^O\:\d+\:\"(OCA \\\\DAV \\\\|Sabre \\\\(Cal|Card)?DAV \\\\Xml \\\\Property \\\\)/ ' , $ value )) {
457470 throw new \LogicException ('Found an object class serialized in DB that is not allowed ' );
458471 }
0 commit comments