diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-11-22 13:03:17 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-11-22 13:03:17 +0100 |
commit | a81d7cd79ff78122521dc0c8db864a9654710863 (patch) | |
tree | 2409bc2388c796e5d69a2f2603d50ca3ba405838 /apps | |
parent | cd495bf9ba47b606c1258f2ab07907b65f5951b7 (diff) | |
download | nextcloud-server-a81d7cd79ff78122521dc0c8db864a9654710863.tar.gz nextcloud-server-a81d7cd79ff78122521dc0c8db864a9654710863.zip |
introduce Files.containsInvalidCharacters(), use when creating or renaming files
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/js/filelist.js | 3 | ||||
-rw-r--r-- | apps/files/js/files.js | 27 |
2 files changed, 19 insertions, 11 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a5550dc9926..5674206632b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -151,6 +151,9 @@ var FileList={ event.stopPropagation(); event.preventDefault(); var newname=input.val(); + if (Files.containsInvalidCharacters(newname)) { + return false; + } if (newname != name) { if (FileList.checkName(name, newname, false)) { newname = name; diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 8d0f9e06ad7..9fa2a384b5d 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -25,6 +25,18 @@ Files={ delete uploadingFiles[index]; }); procesSelection(); + }, + containsInvalidCharacters:function (name) { + 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; + } + } + $('#notification').fadeOut(); + return false; } }; $(document).ready(function() { @@ -505,17 +517,10 @@ $(document).ready(function() { $(this).append(input); input.focus(); input.change(function(){ - if (type != 'web') { - var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; - for (var i = 0; i < invalid_characters.length; i++) { - if ($(this).val().indexOf(invalid_characters[i]) != -1) { - $('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); - $('#notification').fadeIn(); - return; - } - } - } - var name = getUniqueName($(this).val()); + if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { + return; + } + var name = getUniqueName($(this).val()); if (name != $(this).val()) { FileList.checkName(name, $(this).val(), true); var hidden = true; |