From 63b8b326028f4da0d6718bd9d86708f36adaf433 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 23 Aug 2020 12:09:55 +1000 Subject: [PATCH] normalize field before checking duplicates https://forums.ankiweb.net/t/unicode-normalisation/2531 --- rslib/src/notes.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rslib/src/notes.rs b/rslib/src/notes.rs index 35a56d7a6..97079be22 100644 --- a/rslib/src/notes.rs +++ b/rslib/src/notes.rs @@ -10,7 +10,7 @@ use crate::{ err::{AnkiError, Result}, notetype::{CardGenContext, NoteField, NoteType, NoteTypeID}, template::field_is_empty, - text::{ensure_string_in_nfc, strip_html_preserving_image_filenames}, + text::{ensure_string_in_nfc, normalize_to_nfc, strip_html_preserving_image_filenames}, timestamp::TimestampSecs, types::Usn, }; @@ -424,7 +424,12 @@ impl Collection { pub(crate) fn note_is_duplicate_or_empty(&self, note: &Note) -> Result { if let Some(field1) = note.fields.get(0) { - let stripped = strip_html_preserving_image_filenames(field1); + let field1 = if self.normalize_note_text() { + normalize_to_nfc(field1) + } else { + field1.into() + }; + let stripped = strip_html_preserving_image_filenames(&field1); if stripped.trim().is_empty() { Ok(DuplicateState::Empty) } else {