@@ -480,6 +480,18 @@ private function formatPath(string $path): string {
480480 return $ path ;
481481 }
482482
483+ private static function checkIsArrayOfScalar (string $ name , array $ array ): void {
484+ foreach ($ array as $ item ) {
485+ if (is_array ($ item )) {
486+ self ::checkIsArrayOfScalar ($ name , $ item );
487+ } elseif ($ item !== null && !is_scalar ($ item )) {
488+ throw new DavException (
489+ "Property \"$ name \" has an invalid value of array containing " . gettype ($ item ),
490+ );
491+ }
492+ }
493+ }
494+
483495 /**
484496 * @throws ParseException If parsing a \Sabre\DAV\Xml\Property\Complex value fails
485497 * @throws DavException If the property value is invalid
@@ -516,25 +528,20 @@ private function encodeValueForDatabase(string $path, string $name, mixed $value
516528 } else {
517529 if (is_array ($ value )) {
518530 // For array only allow scalar values
519- foreach ($ value as $ item ) {
520- if (!is_scalar ($ item )) {
521- throw new DavException (
522- "Property \"$ name \" has an invalid value of array containing " . gettype ($ value ),
523- );
524- }
525- }
531+ self ::checkIsArrayOfScalar ($ name , $ value );
526532 } elseif (!is_object ($ value )) {
527533 throw new DavException (
528534 "Property \"$ name \" has an invalid value of type " . gettype ($ value ),
529535 );
530- }
531- if (!str_starts_with ($ value ::class, 'Sabre \\DAV \\Xml \\Property \\' )
532- && !str_starts_with ($ value ::class, 'Sabre \\CalDAV \\Xml \\Property \\' )
533- && !str_starts_with ($ value ::class, 'Sabre \\CardDAV \\Xml \\Property \\' )
534- && !str_starts_with ($ value ::class, 'OCA \\DAV \\' )) {
535- throw new DavException (
536- "Property \"$ name \" has an invalid value of class " . $ value ::class,
537- );
536+ } else {
537+ if (!str_starts_with ($ value ::class, 'Sabre \\DAV \\Xml \\Property \\' )
538+ && !str_starts_with ($ value ::class, 'Sabre \\CalDAV \\Xml \\Property \\' )
539+ && !str_starts_with ($ value ::class, 'Sabre \\CardDAV \\Xml \\Property \\' )
540+ && !str_starts_with ($ value ::class, 'OCA \\DAV \\' )) {
541+ throw new DavException (
542+ "Property \"$ name \" has an invalid value of class " . $ value ::class,
543+ );
544+ }
538545 }
539546 $ valueType = self ::PROPERTY_TYPE_OBJECT ;
540547 // serialize produces null character
0 commit comments