From ec87d11c31ae430194d4aacbe8c7d702de094940 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Wed, 31 Jan 2018 22:36:31 -0700 Subject: [PATCH] Fix FileEntry.findFiles() terms MATCH expr --- core/file_entry.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/file_entry.js b/core/file_entry.js index b95c7acb..8738fcbd 100644 --- a/core/file_entry.js +++ b/core/file_entry.js @@ -3,7 +3,10 @@ const fileDb = require('./database.js').dbs.file; const Errors = require('./enig_error.js').Errors; -const getISOTimestampString = require('./database.js').getISOTimestampString; +const { + getISOTimestampString, + sanatizeString +} = require('./database.js'); const Config = require('./config.js').config; // deps @@ -523,11 +526,12 @@ module.exports = class FileEntry { } if(filter.terms && filter.terms.length > 0) { + // note the ':' in MATCH expr., see https://www.sqlite.org/cvstrac/wiki?p=FullTextIndex appendWhereClause( `f.file_id IN ( SELECT rowid FROM file_fts - WHERE file_fts MATCH "${filter.terms.replace(/"/g,'""')}" + WHERE file_fts MATCH ":${sanatizeString(filter.terms)}" )` ); }