From a115b14136bcea7ee2f68572df5e6d1fd77a0b7c Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 2 Mar 2024 07:35:52 +0100 Subject: [PATCH] fix highlighting search results with regexp characters in fulltext string, closes #4665 --- src/public/app/services/note_list_renderer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/public/app/services/note_list_renderer.js b/src/public/app/services/note_list_renderer.js index 639eda9446..a6b0b6f78f 100644 --- a/src/public/app/services/note_list_renderer.js +++ b/src/public/app/services/note_list_renderer.js @@ -4,6 +4,7 @@ import froca from "./froca.js"; import attributeRenderer from "./attribute_renderer.js"; import libraryLoader from "./library_loader.js"; import treeService from "./tree.js"; +import utils from "./utils.js"; const TPL = `
@@ -215,7 +216,11 @@ class NoteListRenderer { if (highlightedTokens.length > 0) { await libraryLoader.requireLibrary(libraryLoader.MARKJS); - this.highlightRegex = new RegExp(highlightedTokens.join("|"), 'gi'); + const regex = highlightedTokens + .map(token => utils.escapeRegExp(token)) + .join("|"); + + this.highlightRegex = new RegExp(regex, 'gi'); } else { this.highlightRegex = null; }