Escape the name for the jquery selector

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2016-12-20 09:32:47 +01:00
parent 084bddf8ae
commit e53d0c0d69
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with 9 additions and 1 deletions

View File

@ -1175,7 +1175,7 @@
var innernameSpan = $('<span></span>').addClass('innernametext').text(basename);
if (path && path !== '/') {
var conflictingItems = this.$fileList.find('tr[data-file="' + name.replace( /(:|\.|\[|\]|,|=)/g, "\\$1") + '"]');
var conflictingItems = this.$fileList.find('tr[data-file="' + this._jqSelEscape(name) + '"]');
if (conflictingItems.length !== 0) {
if (conflictingItems.length === 1) {
// Update the path on the first conflicting item
@ -1261,6 +1261,14 @@
return tr;
},
/* escape a selector expression for jQuery */
_jqSelEscape: function (expression) {
if (expression) {
return expression.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&');
}
return null;
},
/**
* Adds an entry to the files array and also into the DOM
* in a sorted manner.