diff --git a/packages/lib/services/search/SearchEngine.ts b/packages/lib/services/search/SearchEngine.ts index 2c34540ff..bf9226c00 100644 --- a/packages/lib/services/search/SearchEngine.ts +++ b/packages/lib/services/search/SearchEngine.ts @@ -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; }