1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00

Mobile,Desktop,Cli: Improve search engine error handling when preparing text for search (#9871)

Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
Henry Heino 2024-02-09 04:11:08 -08:00 committed by GitHub
parent 6f0fd4219e
commit 296d586b04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -617,8 +617,21 @@ export default class SearchEngine {
private normalizeNote_(note: NoteEntity) {
const n = { ...note };
n.title = this.normalizeText_(n.title);
n.body = this.normalizeText_(n.body);
try {
n.title = this.normalizeText_(n.title);
n.body = this.normalizeText_(n.body);
} catch (error) {
// Text normalization -- specifically removeDiacritics -- can fail in some cases.
// We log additional information to help determine the cause of the issue.
//
// See https://discourse.joplinapp.org/t/search-not-working-on-ios/35754
this.logger().error(`Error while normalizing text for note ${note.id}:`, error);
// Unnormalized text can break the search engine, specifically NUL characters.
// Thus, we remove the text entirely.
n.title = '';
n.body = '';
}
return n;
}