Fix autocomplete for tags beginning with _ or %

Addresses #1598
This commit is contained in:
Dan Stillman 2018-11-25 00:36:04 -07:00
parent 93bccf8fe2
commit 7d9b94c79e
2 changed files with 11 additions and 2 deletions

View file

@ -71,8 +71,8 @@ ZoteroAutoComplete.prototype.startSearch = Zotero.Promise.coroutine(function* (s
break;
case 'tag':
var sql = "SELECT DISTINCT name AS val, NULL AS comment FROM tags WHERE name LIKE ?";
var sqlParams = [searchString + '%'];
var sql = "SELECT DISTINCT name AS val, NULL AS comment FROM tags WHERE name LIKE ? ESCAPE '\\'";
var sqlParams = [Zotero.Utilities.Internal.escapeSQLExpression(searchString) + '%'];
if (searchParams.libraryID !== undefined) {
sql += " AND tagID IN (SELECT tagID FROM itemTags JOIN items USING (itemID) "
+ "WHERE libraryID=?)";