From 749b6cb57e2e19a62f0795ae73bf2401b510821c Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 24 Dec 2020 23:33:42 +0100 Subject: [PATCH] don't strip tags for very large text notes, #1500 --- .../search/expressions/note_content_protected_fulltext.js | 5 ++++- .../search/expressions/note_content_unprotected_fulltext.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/search/expressions/note_content_protected_fulltext.js b/src/services/search/expressions/note_content_protected_fulltext.js index 472fd62f0..fd8bf9128 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(/ /g, ' '); } diff --git a/src/services/search/expressions/note_content_unprotected_fulltext.js b/src/services/search/expressions/note_content_unprotected_fulltext.js index f30679d42..c9212a431 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(/ /g, ' '); }