From 749b6cb57e2e19a62f0795ae73bf2401b510821c Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 24 Dec 2020 23:33:42 +0100 Subject: [PATCH 1/3] 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, ' '); } From a266d6a3d5632dfb3846bd02e516e72593b50f31 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 24 Dec 2020 23:37:21 +0100 Subject: [PATCH 2/3] don't strip tags for very large text notes, #1500 --- .../search/expressions/note_content_protected_fulltext.js | 2 +- .../search/expressions/note_content_unprotected_fulltext.js | 2 +- 2 files changed, 2 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 fd8bf9128..d24838547 100644 --- a/src/services/search/expressions/note_content_protected_fulltext.js +++ b/src/services/search/expressions/note_content_protected_fulltext.js @@ -44,7 +44,7 @@ class NoteContentProtectedFulltextExp extends Expression { if (type === 'text' && mime === 'text/html' - && content.length < 50000 // striptags is very slow for large notes + && content.length < 20000 // 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 c9212a431..7f8df513f 100644 --- a/src/services/search/expressions/note_content_unprotected_fulltext.js +++ b/src/services/search/expressions/note_content_unprotected_fulltext.js @@ -30,7 +30,7 @@ class NoteContentUnprotectedFulltextExp extends Expression { if (type === 'text' && mime === 'text/html' - && content.length < 50000 // striptags is very slow for large notes + && content.length < 20000 // striptags is very slow for large notes ) { content = striptags(content); content = content.replace(/ /g, ' '); From 577dc95ab83bc526a2c18e5d5f26c0daa79db342 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 25 Dec 2020 12:55:16 +0100 Subject: [PATCH 3/3] convert   into whitespace also for large notes --- .../expressions/note_content_protected_fulltext.js | 10 +++++----- .../expressions/note_content_unprotected_fulltext.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/services/search/expressions/note_content_protected_fulltext.js b/src/services/search/expressions/note_content_protected_fulltext.js index d24838547..daed14000 100644 --- a/src/services/search/expressions/note_content_protected_fulltext.js +++ b/src/services/search/expressions/note_content_protected_fulltext.js @@ -42,11 +42,11 @@ class NoteContentProtectedFulltextExp extends Expression { content = content.toLowerCase(); - if (type === 'text' - && mime === 'text/html' - && content.length < 20000 // striptags is very slow for large notes - ) { - content = striptags(content); + if (type === 'text' && mime === 'text/html') { + if (content.length < 20000) { // striptags is slow for very 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 7f8df513f..ad0ce7cdf 100644 --- a/src/services/search/expressions/note_content_unprotected_fulltext.js +++ b/src/services/search/expressions/note_content_unprotected_fulltext.js @@ -28,11 +28,11 @@ class NoteContentUnprotectedFulltextExp extends Expression { content = content.toString().toLowerCase(); - if (type === 'text' - && mime === 'text/html' - && content.length < 20000 // striptags is very slow for large notes - ) { - content = striptags(content); + if (type === 'text' && mime === 'text/html') { + if (content.length < 20000) { // striptags is slow for very large notes + content = striptags(content); + } + content = content.replace(/ /g, ' '); }