1313use OCA \DAV \Connector \Sabre \Exception \FileLocked ;
1414use OCA \DAV \Connector \Sabre \Exception \Forbidden ;
1515use OCA \DAV \Connector \Sabre \Exception \InvalidPath ;
16+ use OCA \DAV \Storage \PublicShareWrapper ;
1617use OCP \App \IAppManager ;
18+ use OCP \Constants ;
1719use OCP \Files \FileInfo ;
1820use OCP \Files \Folder ;
1921use OCP \Files \ForbiddenException ;
@@ -172,7 +174,19 @@ public function createDirectory($name) {
172174 * @throws \Sabre\DAV\Exception\ServiceUnavailable
173175 */
174176 public function getChild ($ name , $ info = null , ?IRequest $ request = null , ?IL10N $ l10n = null ) {
175- if (!$ this ->info ->isReadable ()) {
177+ $ storage = $ this ->info ->getStorage ();
178+ $ allowDirectory = false ;
179+ if ($ storage instanceof PublicShareWrapper) {
180+ $ share = $ storage ->getShare ();
181+ $ allowDirectory =
182+ // Only allow directories for file drops
183+ ($ share ->getPermissions () & Constants::PERMISSION_READ ) !== Constants::PERMISSION_READ &&
184+ // And only allow it for directories which are a direct child of of the share root
185+ $ this ->info ->getId () === $ share ->getNodeId ();
186+ }
187+
188+ // For file drop we need to be allowed to read the directory with the nickname
189+ if (!$ allowDirectory && !$ this ->info ->isReadable ()) {
176190 // avoid detecting files through this way
177191 throw new NotFound ();
178192 }
@@ -198,6 +212,11 @@ public function getChild($name, $info = null, ?IRequest $request = null, ?IL10N
198212 if ($ info ->getMimeType () === FileInfo::MIMETYPE_FOLDER ) {
199213 $ node = new \OCA \DAV \Connector \Sabre \Directory ($ this ->fileView , $ info , $ this ->tree , $ this ->shareManager );
200214 } else {
215+ // In case reading a directory was allowed but it turns out the node was a not a directory, reject it now.
216+ if (!$ this ->info ->isReadable ()) {
217+ throw new NotFound ();
218+ }
219+
201220 $ node = new File ($ this ->fileView , $ info , $ this ->shareManager , $ request , $ l10n );
202221 }
203222 if ($ this ->tree ) {
0 commit comments