Skip to content

Commit bc30345

Browse files
authored
Merge pull request #12461 from nextcloud/bugfix-stable12/dav_shares_hickup
[stable12] fixes dav share issue with owner
2 parents eb1ce1b + 8469103 commit bc30345

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

apps/dav/lib/CalDAV/Calendar.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ public function getACL() {
130130
];
131131
}
132132

133+
if (!$this->isShared()) {
134+
return $acl;
135+
}
136+
133137
if ($this->getOwner() !== parent::getOwner()) {
134138
$acl[] = [
135139
'privilege' => '{DAV:}read',
@@ -159,14 +163,9 @@ public function getACL() {
159163
}
160164

161165
$acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
162-
163-
if (!$this->isShared()) {
164-
return $acl;
165-
}
166-
167166
$allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public'];
168167
return array_filter($acl, function($rule) use ($allowedPrincipals) {
169-
return in_array($rule['principal'], $allowedPrincipals);
168+
return \in_array($rule['principal'], $allowedPrincipals, true);
170169
});
171170
}
172171

apps/dav/lib/CardDAV/AddressBook.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,17 @@ public function getACL() {
104104
'privilege' => '{DAV:}read',
105105
'principal' => $this->getOwner(),
106106
'protected' => true,
107-
]];
108-
$acl[] = [
107+
],[
109108
'privilege' => '{DAV:}write',
110109
'principal' => $this->getOwner(),
111110
'protected' => true,
112-
];
111+
]
112+
];
113+
114+
if (!$this->isShared()) {
115+
return $acl;
116+
}
117+
113118
if ($this->getOwner() !== parent::getOwner()) {
114119
$acl[] = [
115120
'privilege' => '{DAV:}read',
@@ -132,11 +137,11 @@ public function getACL() {
132137
];
133138
}
134139

135-
if ($this->isShared()) {
136-
return $acl;
137-
}
138-
139-
return $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl);
140+
$acl = $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl);
141+
$allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/system'];
142+
return array_filter($acl, function($rule) use ($allowedPrincipals) {
143+
return \in_array($rule['principal'], $allowedPrincipals, true);
144+
});
140145
}
141146

142147
public function getChildACL() {

apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<description>Shared calendar exists</description>
7474
<request user="$userid2:" pswd="$pswd2:">
7575
<method>PROPFIND</method>
76-
<ruri>$calendarhome1:/shared/</ruri>
76+
<ruri>$calendarhome2:/shared_shared_by_user01/</ruri>
7777
<header>
7878
<name>Depth</name>
7979
<value>0</value>
@@ -193,7 +193,7 @@
193193
<description>Sharee creates event</description>
194194
<request user="$userid2:" pswd="$pswd2:">
195195
<method>PUT</method>
196-
<ruri>$calendarhome1:/shared/1.ics</ruri>
196+
<ruri>$calendarhome2:/shared_shared_by_user01/1.ics</ruri>
197197
<data>
198198
<content-type>text/calendar; charset=utf-8</content-type>
199199
<filepath>Resource/CalDAV/sharing/calendars/read-write/5.ics</filepath>
@@ -235,7 +235,7 @@
235235
<description>Sharee sees changed event</description>
236236
<request user="$userid2:" pswd="$pswd2:">
237237
<method>GET</method>
238-
<ruri>$calendarhome1:/shared/1.ics</ruri>
238+
<ruri>$calendarhome2:/shared_shared_by_user01/1.ics</ruri>
239239
<verify>
240240
<callback>calendarDataMatch</callback>
241241
<arg>
@@ -263,7 +263,7 @@
263263
<description>Sharee sees new event</description>
264264
<request user="$userid2:" pswd="$pswd2:">
265265
<method>GET</method>
266-
<ruri>$calendarhome1:/shared/2.ics</ruri>
266+
<ruri>$calendarhome2:/shared_shared_by_user01/2.ics</ruri>
267267
<verify>
268268
<callback>calendarDataMatch</callback>
269269
<arg>
@@ -277,7 +277,7 @@
277277
<description>Sharee changes event</description>
278278
<request user="$userid2:" pswd="$pswd2:">
279279
<method>PUT</method>
280-
<ruri>$calendarhome1:/shared/2.ics</ruri>
280+
<ruri>$calendarhome2:/shared_shared_by_user01/2.ics</ruri>
281281
<data>
282282
<content-type>text/calendar; charset=utf-8</content-type>
283283
<filepath>Resource/CalDAV/sharing/calendars/read-write/8.ics</filepath>

apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<description>POST invitation</description>
1818
<request>
1919
<method>POST</method>
20-
<ruri>$addressbookpath1:</ruri>
20+
<ruri>$addressbookhome1:/addressbook/</ruri>
2121
<data>
2222
<content-type>text/xml; charset=utf-8</content-type>
2323
<filepath>Resource/CardDAV/sharing/read-write/1.xml</filepath>
@@ -31,7 +31,7 @@
3131
<description>Shared addressbook exists</description>
3232
<request user="$userid2:" pswd="$pswd2:">
3333
<method>PROPFIND</method>
34-
<ruri>$addressbookpath1:/</ruri>
34+
<ruri>$addressbookhome2:/addressbook_shared_by_user01/</ruri>
3535
<header>
3636
<name>Depth</name>
3737
<value>0</value>
@@ -62,7 +62,7 @@
6262
</test>
6363

6464
<test name='4a'>
65-
<description>Shared calendar exists Depth:1</description>
65+
<description>Shared addressbook exists Depth:1</description>
6666
<request user="$userid2:" pswd="$pswd2:">
6767
<method>PROPFIND</method>
6868
<ruri>$addressbookhome2:/</ruri>
@@ -100,7 +100,7 @@
100100
</test>
101101

102102
<test name='5'>
103-
<description>Original calendar unchanged</description>
103+
<description>Original addressbook unchanged</description>
104104
<request>
105105
<method>PROPFIND</method>
106106
<ruri>$addressbookpath1:</ruri>
@@ -126,7 +126,7 @@
126126
<description>Sharee creates contact</description>
127127
<request user="$userid2:" pswd="$pswd2:">
128128
<method>PUT</method>
129-
<ruri>$addressbookpath1:/1.vcf</ruri>
129+
<ruri>$addressbookhome2:/addressbook_shared_by_user01/1.vcf</ruri>
130130
<data>
131131
<content-type>text/vcard; charset=utf-8</content-type>
132132
<filepath>Resource/CardDAV/sharing/read-write/6.vcf</filepath>
@@ -171,7 +171,7 @@
171171
<description>Sharee sees changed contact</description>
172172
<request user="$userid2:" pswd="$pswd2:">
173173
<method>GET</method>
174-
<ruri>$addressbookpath1:/1.vcf</ruri>
174+
<ruri>$addressbookhome2:/addressbook_shared_by_user01/1.vcf</ruri>
175175
<verify>
176176
<callback>addressDataMatch</callback>
177177
<arg>
@@ -183,7 +183,7 @@
183183
</test>
184184

185185
<test name='10'>
186-
<description>Sharer creates event</description>
186+
<description>Sharer creates contact</description>
187187
<request>
188188
<method>PUT</method>
189189
<ruri>$addressbookpath1:/2.vcf</ruri>
@@ -197,10 +197,10 @@
197197
</request>
198198
</test>
199199
<test name='11'>
200-
<description>Sharee sees new event</description>
200+
<description>Sharee sees new contact</description>
201201
<request user="$userid2:" pswd="$pswd2:">
202202
<method>GET</method>
203-
<ruri>$addressbookpath1:/2.vcf</ruri>
203+
<ruri>$addressbookhome2:/addressbook_shared_by_user01/2.vcf</ruri>
204204
<verify>
205205
<callback>addressDataMatch</callback>
206206
<arg>
@@ -211,10 +211,10 @@
211211
</request>
212212
</test>
213213
<test name='12'>
214-
<description>Sharee changes event</description>
214+
<description>Sharee changes contact</description>
215215
<request user="$userid2:" pswd="$pswd2:">
216216
<method>PUT</method>
217-
<ruri>$addressbookpath1:/2.vcf</ruri>
217+
<ruri>$addressbookhome2:/addressbook_shared_by_user01/2.vcf</ruri>
218218
<data>
219219
<content-type>text/vcard; charset=utf-8</content-type>
220220
<filepath>Resource/CardDAV/sharing/read-write/9.vcf</filepath>
@@ -225,7 +225,7 @@
225225
</request>
226226
</test>
227227
<test name='13'>
228-
<description>Sharer sees changed event</description>
228+
<description>Sharer sees changed contact</description>
229229
<request>
230230
<method>GET</method>
231231
<ruri>$addressbookpath1:/2.vcf</ruri>
@@ -281,7 +281,7 @@
281281
</verify> </request>
282282
</test>
283283
<test name='16'>
284-
<description>Shared calendar no longer exists Depth:1</description>
284+
<description>Shared addressbook no longer exists Depth:1</description>
285285
<request user="$userid2:" pswd="$pswd2:">
286286
<method>PROPFIND</method>
287287
<ruri>$addressbookhome2:</ruri>

0 commit comments

Comments
 (0)