diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a8daeadfd2..c8ab8e15b7 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1175,7 +1175,7 @@ var innernameSpan = $('').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.