summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/newfile.php9
-rw-r--r--apps/files/ajax/newfolder.php9
-rw-r--r--apps/files/ajax/upload.php6
3 files changed, 22 insertions, 2 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index ec5b716fb2a..1853098c507 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -64,6 +64,15 @@ if(strpos($filename, '/') !== false) {
exit();
}
+if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
+ $result['data'] = array('message' => (string)$l10n->t(
+ 'The target folder has been moved or deleted.'),
+ 'code' => 'targetnotfound'
+ );
+ OCP\JSON::error($result);
+ exit();
+}
+
//TODO why is stripslashes used on foldername in newfolder.php but not here?
$target = $dir.'/'.$filename;
diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php
index 2cbc8cfeba5..4cfcae3090d 100644
--- a/apps/files/ajax/newfolder.php
+++ b/apps/files/ajax/newfolder.php
@@ -29,6 +29,15 @@ if(strpos($foldername, '/') !== false) {
exit();
}
+if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
+ $result['data'] = array('message' => (string)$l10n->t(
+ 'The target folder has been moved or deleted.'),
+ 'code' => 'targetnotfound'
+ );
+ OCP\JSON::error($result);
+ exit();
+}
+
//TODO why is stripslashes used on foldername here but not in newfile.php?
$target = $dir . '/' . stripslashes($foldername);
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index bdaf6a77d14..8f6c42d6620 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -8,6 +8,7 @@ OCP\JSON::setContentTypeHeader('text/plain');
// If no token is sent along, rely on login only
$allowedPermissions = OCP\PERMISSION_ALL;
+$errorCode = null;
$l = OC_L10N::get('files');
if (empty($_POST['dirToken'])) {
@@ -125,7 +126,8 @@ if (strpos($dir, '..') === false) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
if ($meta === false) {
- $error = $l->t('Upload failed. Could not get file info.');
+ $error = $l->t('The target folder has been moved or deleted.');
+ $errorCode = 'targetnotfound';
} else {
$result[] = array('status' => 'success',
'mime' => $meta['mimetype'],
@@ -177,5 +179,5 @@ if ($error === false) {
OCP\JSON::encodedPrint($result);
exit();
} else {
- OCP\JSON::error(array(array('data' => array_merge(array('message' => $error), $storageStats))));
+ OCP\JSON::error(array(array('data' => array_merge(array('message' => $error, 'code' => $errorCode), $storageStats))));
}