|
12 | 12 | use OCA\DAV\CalDAV\CalendarObject; |
13 | 13 | use OCA\DAV\CalDAV\DefaultCalendarValidator; |
14 | 14 | use OCA\DAV\Connector\Sabre\Directory; |
15 | | -use OCA\DAV\Connector\Sabre\FilesPlugin; |
16 | 15 | use OCP\DB\QueryBuilder\IQueryBuilder; |
17 | 16 | use OCP\IDBConnection; |
18 | 17 | use OCP\IUser; |
@@ -66,38 +65,16 @@ class CustomPropertiesBackend implements BackendInterface { |
66 | 65 | '{DAV:}getetag', |
67 | 66 | '{DAV:}quota-used-bytes', |
68 | 67 | '{DAV:}quota-available-bytes', |
69 | | - '{http://owncloud.org/ns}permissions', |
70 | | - '{http://owncloud.org/ns}downloadURL', |
71 | | - '{http://owncloud.org/ns}dDC', |
72 | | - '{http://owncloud.org/ns}size', |
73 | | - '{http://nextcloud.org/ns}is-encrypted', |
74 | | - |
75 | | - // Currently, returning null from any propfind handler would still trigger the backend, |
76 | | - // so we add all known Nextcloud custom properties in here to avoid that |
77 | | - |
78 | | - // text app |
79 | | - '{http://nextcloud.org/ns}rich-workspace', |
80 | | - '{http://nextcloud.org/ns}rich-workspace-file', |
81 | | - // groupfolders |
82 | | - '{http://nextcloud.org/ns}acl-enabled', |
83 | | - '{http://nextcloud.org/ns}acl-can-manage', |
84 | | - '{http://nextcloud.org/ns}acl-list', |
85 | | - '{http://nextcloud.org/ns}inherited-acl-list', |
86 | | - '{http://nextcloud.org/ns}group-folder-id', |
87 | | - // files_lock |
88 | | - '{http://nextcloud.org/ns}lock', |
89 | | - '{http://nextcloud.org/ns}lock-owner-type', |
90 | | - '{http://nextcloud.org/ns}lock-owner', |
91 | | - '{http://nextcloud.org/ns}lock-owner-displayname', |
92 | | - '{http://nextcloud.org/ns}lock-owner-editor', |
93 | | - '{http://nextcloud.org/ns}lock-time', |
94 | | - '{http://nextcloud.org/ns}lock-timeout', |
95 | | - '{http://nextcloud.org/ns}lock-token', |
96 | | - // photos |
97 | | - '{http://nextcloud.org/ns}realpath', |
98 | | - '{http://nextcloud.org/ns}nbItems', |
99 | | - '{http://nextcloud.org/ns}face-detections', |
100 | | - '{http://nextcloud.org/ns}face-preview-image', |
| 68 | + ]; |
| 69 | + |
| 70 | + /** |
| 71 | + * Allowed properties for the oc/nc namespace, all other properties in the namespace are ignored |
| 72 | + * |
| 73 | + * @var string[] |
| 74 | + */ |
| 75 | + private const ALLOWED_NC_PROPERTIES = [ |
| 76 | + '{http://owncloud.org/ns}calendar-enabled', |
| 77 | + '{http://owncloud.org/ns}enabled', |
101 | 78 | ]; |
102 | 79 |
|
103 | 80 | /** |
@@ -155,14 +132,9 @@ public function __construct( |
155 | 132 | public function propFind($path, PropFind $propFind) { |
156 | 133 | $requestedProps = $propFind->get404Properties(); |
157 | 134 |
|
158 | | - // these might appear |
159 | | - $requestedProps = array_diff( |
160 | | - $requestedProps, |
161 | | - self::IGNORED_PROPERTIES, |
162 | | - ); |
163 | 135 | $requestedProps = array_filter( |
164 | 136 | $requestedProps, |
165 | | - fn ($prop) => !str_starts_with($prop, FilesPlugin::FILE_METADATA_PREFIX), |
| 137 | + $this->isPropertyAllowed(...), |
166 | 138 | ); |
167 | 139 |
|
168 | 140 | // substr of calendars/ => path is inside the CalDAV component |
@@ -249,6 +221,16 @@ public function propFind($path, PropFind $propFind) { |
249 | 221 | } |
250 | 222 | } |
251 | 223 |
|
| 224 | + private function isPropertyAllowed(string $property): bool { |
| 225 | + if (in_array($property, self::IGNORED_PROPERTIES)) { |
| 226 | + return false; |
| 227 | + } |
| 228 | + if (str_starts_with($property, '{http://owncloud.org/ns}') || str_starts_with($property, '{http://nextcloud.org/ns}')) { |
| 229 | + return in_array($property, self::ALLOWED_NC_PROPERTIES); |
| 230 | + } |
| 231 | + return true; |
| 232 | + } |
| 233 | + |
252 | 234 | /** |
253 | 235 | * Updates properties for a path |
254 | 236 | * |
|
0 commit comments