Skip to content

Commit

Permalink
fix: excape special chars in context to fts5 extension
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Apr 14, 2023
1 parent ba0bcf9 commit b02c88f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const safeMirrorDbHandler = (callback) => {
export const sanitizeSqliteFtsQuery = (query) => {
query = query.replace(/[-](?=.*[-])/g, '+'); // Replace all but the final dash
query = query.replace('-', ''); //Replace the final dash with nothing
query = query.replace(/([.?*+^$[\]\\(){}|-])/g, '"$1"');
query += '*'; // Query should end with asterisk for partial matching
return query;
};
Expand Down
5 changes: 1 addition & 4 deletions src/models/projects/projects.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,10 @@ class Project extends Model {
};
}

static async findAllSqliteFts(searchStr, orgUid, pagination, columns = []) {
static async findAllSqliteFts(searchStr, orgUid, pagination) {
const { offset, limit } = pagination;

let fields = '*';
if (columns.length) {
fields = columns.join(', ');
}

searchStr = sanitizeSqliteFtsQuery(searchStr);

Expand Down

0 comments on commit b02c88f

Please sign in to comment.