Skip to content

Commit d0e130c

Browse files
committed
Use a proper upload file so propfinds return 404
Fixes #20235 By using an UploadFile we make sure that we don't need to have another check everywhere for the path. But we just have ot check (which we have to anyway) if it is a proper Connector/File (or directory). Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
1 parent b1a90da commit d0e130c

File tree

4 files changed

+87
-2
lines changed

4 files changed

+87
-2
lines changed

apps/dav/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
'OCA\\DAV\\Upload\\CleanupService' => $baseDir . '/../lib/Upload/CleanupService.php',
224224
'OCA\\DAV\\Upload\\FutureFile' => $baseDir . '/../lib/Upload/FutureFile.php',
225225
'OCA\\DAV\\Upload\\RootCollection' => $baseDir . '/../lib/Upload/RootCollection.php',
226+
'OCA\\DAV\\Upload\\UploadFile' => $baseDir . '/../lib/Upload/UploadFile.php',
226227
'OCA\\DAV\\Upload\\UploadFolder' => $baseDir . '/../lib/Upload/UploadFolder.php',
227228
'OCA\\DAV\\Upload\\UploadHome' => $baseDir . '/../lib/Upload/UploadHome.php',
228229
);

apps/dav/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class ComposerStaticInitDAV
238238
'OCA\\DAV\\Upload\\CleanupService' => __DIR__ . '/..' . '/../lib/Upload/CleanupService.php',
239239
'OCA\\DAV\\Upload\\FutureFile' => __DIR__ . '/..' . '/../lib/Upload/FutureFile.php',
240240
'OCA\\DAV\\Upload\\RootCollection' => __DIR__ . '/..' . '/../lib/Upload/RootCollection.php',
241+
'OCA\\DAV\\Upload\\UploadFile' => __DIR__ . '/..' . '/../lib/Upload/UploadFile.php',
241242
'OCA\\DAV\\Upload\\UploadFolder' => __DIR__ . '/..' . '/../lib/Upload/UploadFolder.php',
242243
'OCA\\DAV\\Upload\\UploadHome' => __DIR__ . '/..' . '/../lib/Upload/UploadHome.php',
243244
);

apps/dav/lib/Upload/UploadFile.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
declare(strict_types=1);
3+
/**
4+
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
5+
*
6+
* @author Roeland Jago Douma <roeland@famdouma.nl>
7+
*
8+
* @license GNU AGPL version 3 or any later version
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Affero General Public License as
12+
* published by the Free Software Foundation, either version 3 of the
13+
* License, or (at your option) any later version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Affero General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Affero General Public License
21+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
*
23+
*/
24+
25+
namespace OCA\DAV\Upload;
26+
27+
use OCA\DAV\Connector\Sabre\File;
28+
use Sabre\DAV\IFile;
29+
30+
class UploadFile implements IFile {
31+
32+
/** @var File */
33+
private $file;
34+
35+
public function __construct(File $file) {
36+
$this->file = $file;
37+
}
38+
39+
public function put($data) {
40+
return $this->file->put($data);
41+
}
42+
43+
public function get() {
44+
return $this->file->get();
45+
}
46+
47+
public function getContentType() {
48+
return $this->file->getContentType();
49+
}
50+
51+
public function getETag() {
52+
return $this->file->getETag();
53+
}
54+
55+
public function getSize() {
56+
return $this->file->getSize();
57+
}
58+
59+
public function delete() {
60+
$this->file->delete();
61+
}
62+
63+
public function getName() {
64+
return $this->file->getName();
65+
}
66+
67+
public function setName($name) {
68+
$this->file->setName($name);
69+
}
70+
71+
public function getLastModified() {
72+
return $this->file->getLastModified();
73+
}
74+
75+
76+
}

apps/dav/lib/Upload/UploadFolder.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,19 @@ public function getChild($name) {
5353
if ($name === '.file') {
5454
return new FutureFile($this->node, '.file');
5555
}
56-
return $this->node->getChild($name);
56+
return new UploadFile($this->node->getChild($name));
5757
}
5858

5959
public function getChildren() {
60-
$children = $this->node->getChildren();
60+
$tmpChildren = $this->node->getChildren();
61+
62+
$children = [];
6163
$children[] = new FutureFile($this->node, '.file');
64+
65+
foreach ($tmpChildren as $child) {
66+
$children[] = new UploadFile($child);
67+
}
68+
6269
return $children;
6370
}
6471

0 commit comments

Comments
 (0)