@@ -565,7 +565,16 @@ private function encodeValueForDatabase(string $path, string $name, mixed $value
565565 $ valueType = self ::PROPERTY_TYPE_HREF ;
566566 $ value = $ value ->getHref ();
567567 } else {
568- if (!is_object ($ value )) {
568+ if (is_array ($ value )) {
569+ // For array only allow scalar values
570+ foreach ($ value as $ item ) {
571+ if (!is_scalar ($ item )) {
572+ throw new DavException (
573+ "Property \"$ name \" has an invalid value of array containing " . gettype ($ value ),
574+ );
575+ }
576+ }
577+ } elseif (!is_object ($ value )) {
569578 throw new DavException (
570579 "Property \"$ name \" has an invalid value of type " . gettype ($ value ),
571580 );
@@ -596,6 +605,10 @@ private function decodeValueFromDatabase(string $value, int $valueType): mixed {
596605 case self ::PROPERTY_TYPE_HREF :
597606 return new Href ($ value );
598607 case self ::PROPERTY_TYPE_OBJECT :
608+ if (preg_match ('/^a:/ ' , $ value )) {
609+ // Array, unserialize only scalar values
610+ return unserialize (str_replace ('\x00 ' , chr (0 ), $ value ), ['allowed_classes ' => false ]);
611+ }
599612 if (!preg_match ('/^O\:\d+\:\"(OCA \\\\DAV \\\\|Sabre \\\\(Cal|Card)?DAV \\\\Xml \\\\Property \\\\)/ ' , $ value )) {
600613 throw new \LogicException ('Found an object class serialized in DB that is not allowed ' );
601614 }
0 commit comments