fix allowed rename of folder in root directory to reserved name "Shared"

refs #2159
This commit is contained in:
Morris Jobke 2013-04-09 13:31:12 +02:00
parent 564f26475c
commit a878bd9923
1 changed files with 4 additions and 2 deletions

View File

@ -13,7 +13,7 @@ $newname = stripslashes($_GET["newname"]);
$l = OC_L10N::get('files');
if ( $newname !== '.' and ($dir != '' || $file != 'Shared') and $newname !== '.') {
if ( $newname !== '.' and ($dir != '' || $file != 'Shared') and $newname !== 'Shared' ) {
$targetFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $newname);
$sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {
@ -21,6 +21,8 @@ if ( $newname !== '.' and ($dir != '' || $file != 'Shared') and $newname !== '.'
} else {
OCP\JSON::error(array("data" => array( "message" => $l->t("Unable to rename file") )));
}
}else{
} elseif( $newname === 'Shared' ) {
OCP\JSON::error(array("data" => array( "message" => $l->t("Invalid folder name. Usage of 'Shared' is reserved by Owncloud") )));
} else {
OCP\JSON::error(array("data" => array( "message" => $l->t("Unable to rename file") )));
}