diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-01-06 07:25:12 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-01-06 07:25:12 -0800 |
commit | 08d7b8ce309baebfc243727c215b63e732bf874e (patch) | |
tree | 8d334d52b191df7f01951e754988f318d0b2af2a | |
parent | da7a14e9a6cc5a388ae817a226af7fa262fe6846 (diff) | |
parent | b4191b7da53f4aaf7e0a80c6513db3499a76aeda (diff) | |
download | nextcloud-server-08d7b8ce309baebfc243727c215b63e732bf874e.tar.gz nextcloud-server-08d7b8ce309baebfc243727c215b63e732bf874e.zip |
Merge pull request #1092 from owncloud/rename_dot
Files: prevent people from renaming files to '.'
-rw-r--r-- | apps/files/ajax/rename.php | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 2 | ||||
-rw-r--r-- | apps/files/js/files.js | 20 |
3 files changed, 18 insertions, 6 deletions
diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php index 45448279fa1..cb0bec399d1 100644 --- a/apps/files/ajax/rename.php +++ b/apps/files/ajax/rename.php @@ -12,7 +12,7 @@ $file = stripslashes($_GET["file"]); $newname = stripslashes($_GET["newname"]); // Delete -if( OC_Files::move( $dir, $file, $dir, $newname )) { +if( $newname !== '.' and OC_Files::move( $dir, $file, $dir, $newname )) { OCP\JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname ))); } else{ diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 96dd0323d29..22d701d8ff9 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -149,7 +149,7 @@ var FileList={ event.stopPropagation(); event.preventDefault(); var newname=input.val(); - if (Files.containsInvalidCharacters(newname)) { + if (!Files.isFileNameValid(newname)) { return false; } if (newname != name) { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6a37d9e7f53..ba2495eb728 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,17 +26,29 @@ Files={ }); procesSelection(); }, - containsInvalidCharacters:function (name) { + isFileNameValid:function (name) { + if (name === '.') { + $('#notification').text(t('files', "'.' is an invalid file name.")); + $('#notification').fadeIn(); + return false; + } + if (name.length == 0) { + $('#notification').text(t('files', "File name cannot be empty.")); + $('#notification').fadeIn(); + return false; + } + + // check for invalid characters var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { $('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); $('#notification').fadeIn(); - return true; + return false; } } $('#notification').fadeOut(); - return false; + return true; } }; $(document).ready(function() { @@ -509,7 +521,7 @@ $(document).ready(function() { $(this).append(input); input.focus(); input.change(function(){ - if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { + if (type != 'web' && !Files.isFileNameValid($(this).val())) { return; } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); |