Merge pull request #2776 from nextcloud/prevent-quotes-from-being-a-problem

Escape the name for the jquery selector
This commit is contained in:
Morris Jobke 2017-01-17 18:40:11 -06:00 committed by GitHub
commit 08cdcf8f7f
1 changed files with 9 additions and 1 deletions

View File

@ -1180,7 +1180,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
@ -1266,6 +1266,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.