From: Thomas Mueller Date: Sun, 6 Jan 2013 11:52:00 +0000 (+0100) Subject: rename containsInvalidCharacters() to isFileNameValid() - NOTE: semantic has changed! X-Git-Tag: v5.0.0alpha1~257^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b4191b7da53f4aaf7e0a80c6513db3499a76aeda;p=nextcloud-server.git rename containsInvalidCharacters() to isFileNameValid() - NOTE: semantic has changed! adding file name checks and notifications to isFileNameValid() for . and empty file name --- diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index cc47ec2612e..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) || 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'));