introduce Files.containsInvalidCharacters(), use when creating or renaming files
This commit is contained in:
parent
cd495bf9ba
commit
a81d7cd79f
|
@ -151,6 +151,9 @@ var FileList={
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var newname=input.val();
|
var newname=input.val();
|
||||||
|
if (Files.containsInvalidCharacters(newname)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (newname != name) {
|
if (newname != name) {
|
||||||
if (FileList.checkName(name, newname, false)) {
|
if (FileList.checkName(name, newname, false)) {
|
||||||
newname = name;
|
newname = name;
|
||||||
|
|
|
@ -25,6 +25,18 @@ Files={
|
||||||
delete uploadingFiles[index];
|
delete uploadingFiles[index];
|
||||||
});
|
});
|
||||||
procesSelection();
|
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() {
|
$(document).ready(function() {
|
||||||
|
@ -505,17 +517,10 @@ $(document).ready(function() {
|
||||||
$(this).append(input);
|
$(this).append(input);
|
||||||
input.focus();
|
input.focus();
|
||||||
input.change(function(){
|
input.change(function(){
|
||||||
if (type != 'web') {
|
if (type != 'web' && Files.containsInvalidCharacters($(this).val())) {
|
||||||
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
|
return;
|
||||||
for (var i = 0; i < invalid_characters.length; i++) {
|
}
|
||||||
if ($(this).val().indexOf(invalid_characters[i]) != -1) {
|
var name = getUniqueName($(this).val());
|
||||||
$('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
|
|
||||||
$('#notification').fadeIn();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var name = getUniqueName($(this).val());
|
|
||||||
if (name != $(this).val()) {
|
if (name != $(this).val()) {
|
||||||
FileList.checkName(name, $(this).val(), true);
|
FileList.checkName(name, $(this).val(), true);
|
||||||
var hidden = true;
|
var hidden = true;
|
||||||
|
|
Loading…
Reference in New Issue