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