diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index 151886369d..279165b927 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -1090,6 +1090,15 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function }); +/** + * Escape '_', '%', and '\' in an SQL LIKE expression so that it can be used with ESCAPE '\' to + * prevent the wildcards from having special meaning + */ +Zotero.DBConnection.prototype.escapeSQLExpression = function (expr) { + return expr.replace(/([_%\\])/g, '\\$1'); +}; + + ///////////////////////////////////////////////////////////////// // // Private methods diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 1c4cedc555..a7ac0bbdd9 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1164,15 +1164,6 @@ Zotero.Utilities.Internal = { }, - /** - * Escape '_', '%', and '\' in an SQL LIKE expression so that it can be used with ESCAPE '\' to - * prevent the wildcards from having special meaning - */ - escapeSQLExpression: function (expr) { - return expr.replace(/([_%\\])/g, '\\$1'); - }, - - buildLibraryMenu: function (menulist, libraries, selectedLibraryID) { var menupopup = menulist.firstChild; while (menupopup.hasChildNodes()) { diff --git a/components/zotero-autocomplete.js b/components/zotero-autocomplete.js index 60c3773a23..f41b944baa 100644 --- a/components/zotero-autocomplete.js +++ b/components/zotero-autocomplete.js @@ -72,7 +72,7 @@ ZoteroAutoComplete.prototype.startSearch = Zotero.Promise.coroutine(function* (s case 'tag': var sql = "SELECT DISTINCT name AS val, NULL AS comment FROM tags WHERE name LIKE ? ESCAPE '\\'"; - var sqlParams = [Zotero.Utilities.Internal.escapeSQLExpression(searchString) + '%']; + var sqlParams = [Zotero.DB.escapeSQLExpression(searchString) + '%']; if (searchParams.libraryID !== undefined) { sql += " AND tagID IN (SELECT tagID FROM itemTags JOIN items USING (itemID) " + "WHERE libraryID=?)";