Skip to content

Build your personal knowledge base with Trilium Notes

don't strip tags for very large text notes, #1500

zadam749b6cb57e2e
diff --git a/src/services/search/expressions/note_content_protected_fulltext.js b/src/services/search/expressions/note_content_protected_fulltext.js
index 472fd62f0b..fd8bf91287 100644
--- a/src/services/search/expressions/note_content_protected_fulltext.js
+++ b/src/services/search/expressions/note_content_protected_fulltext.js
@@ -42,7 +42,10 @@ class NoteContentProtectedFulltextExp extends Expression {
content = content.toLowerCase();
- if (type === 'text' && mime === 'text/html') {
+ if (type === 'text'
+ && mime === 'text/html'
+ && content.length < 50000 // striptags is very slow for large notes
+ ) {
content = striptags(content);
content = content.replace(/&nbsp;/g, ' ');
}
diff --git a/src/services/search/expressions/note_content_unprotected_fulltext.js b/src/services/search/expressions/note_content_unprotected_fulltext.js
index f30679d425..c9212a4313 100644
--- a/src/services/search/expressions/note_content_unprotected_fulltext.js
+++ b/src/services/search/expressions/note_content_unprotected_fulltext.js
@@ -28,7 +28,10 @@ class NoteContentUnprotectedFulltextExp extends Expression {
content = content.toString().toLowerCase();
- if (type === 'text' && mime === 'text/html') {
+ if (type === 'text'
+ && mime === 'text/html'
+ && content.length < 50000 // striptags is very slow for large notes
+ ) {
content = striptags(content);
content = content.replace(/&nbsp;/g, ' ');
}