Skip to content

Commit

Permalink
fix highlighting search results with regexp characters in fulltext st…
Browse files Browse the repository at this point in the history
…ring, closes #4665
  • Loading branch information
zadam committed Mar 2, 2024
1 parent 2d19f07 commit a115b14
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/public/app/services/note_list_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<div class="note-list">
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a115b14

Please sign in to comment.