A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: properly escape fts query
Abdullah Atta2f62c72cfe0f
diff --git a/packages/core/src/api/lookup.ts b/packages/core/src/api/lookup.tsindex cd2d61a98..703035eda 100644--- a/packages/core/src/api/lookup.ts+++ b/packages/core/src/api/lookup.ts@@ -42,16 +42,17 @@ export default class Lookup {notes(query: string, noteIds?: string[]) {return this.toSearchResults(async (limit) => {const db = this.db.sql() as Kysely<DatabaseSchemaWithFTS>;+ query = query.replace(/"/, '""');const result = await db.with("matching", (eb) =>eb.selectFrom("content_fts")- .where("data", "match", query)+ .where("data", "match", `"${query}"`).select(["noteId as id", "rank"]).unionAll(eb.selectFrom("notes_fts")- .where("title", "match", query)+ .where("title", "match", `"${query}"`)// add 10 weight to title.select(["id", sql.raw<number>(`rank * 10`).as("rank")]))