Skip to content

Commit 8f5509c

Browse files
authored
Merge pull request #2439 from nextcloud/stable9-dont-allow-subfolders-for-write-only-shares
[stable9] On write-only shares do not allow to specify subfolders
2 parents 8468d7a + e492474 commit 8f5509c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

apps/files/ajax/upload.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,22 @@
5656
die();
5757
}
5858
} else {
59+
$shareManager = \OC::$server->getShareManager();
60+
$share = $shareManager->getShareByToken((string)$_POST['dirToken']);
61+
5962
// TODO: ideally this code should be in files_sharing/ajax/upload.php
6063
// and the upload/file transfer code needs to be refactored into a utility method
6164
// that could be used there
6265

6366
\OC_User::setIncognitoMode(true);
6467

65-
$publicDirectory = !empty($_POST['subdir']) ? (string)$_POST['subdir'] : '/';
68+
// If it is a write-only folder no subdirectory can be specified
69+
$publicDirectory = '';
70+
if ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) {
71+
$publicDirectory = !empty($_POST['subdir']) ? (string)$_POST['subdir'] : '/';
72+
} else {
73+
$_POST['file_directory'] = '';
74+
}
6675

6776
$linkItem = OCP\Share::getShareByToken((string)$_POST['dirToken']);
6877
if ($linkItem === false) {
@@ -165,8 +174,6 @@
165174

166175
if(isset($_POST['dirToken'])) {
167176
// If it is a read only share the resolution will always be autorename
168-
$shareManager = \OC::$server->getShareManager();
169-
$share = $shareManager->getShareByToken((string)$_POST['dirToken']);
170177
if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
171178
$resolution = 'autorename';
172179
}

0 commit comments

Comments
 (0)