From a05d84b637d214e3dcf870d8aba755bdf1bdfc25 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Sun, 24 Sep 2023 09:07:24 +0200 Subject: [PATCH] #2858 evernote: handle malformed XML --- CHANGELOG.md | 4 +++ src/dialogs/evernoteimportdialog.cpp | 9 +++++ src/languages/QOwnNotes_en.ts | 54 ++++++++++++++++------------ 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e08dcf8cc1..c8147976f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # QOwnNotes Changelog +## 23.9.7 +- Evernote notes with malformed XML will now stop the import process when importing + them in the Evernote import (for [#2858](https://github.com/pbek/QOwnNotes/issues/2858)) + ## 23.9.6 - an issue with duplicate imported media files and attachments when importing notes from Evernote was fixed (for [#2859](https://github.com/pbek/QOwnNotes/issues/2859)) diff --git a/src/dialogs/evernoteimportdialog.cpp b/src/dialogs/evernoteimportdialog.cpp index 9262dfa33c..3e9417651f 100644 --- a/src/dialogs/evernoteimportdialog.cpp +++ b/src/dialogs/evernoteimportdialog.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -180,6 +181,14 @@ Note EvernoteImportDialog::parseNote(QXmlStreamReader &xml, bool importMetaData) parseMetaDataItem(xml); } } + } else if (xml.tokenType() == QXmlStreamReader::Invalid) { + // Stop parsing on invalid tokens + // See: https://github.com/pbek/QOwnNotes/issues/2858 + Utils::Gui::warning(this, tr("Invalid XML!"), + tr("Invalid XML found in note %1! The import might be stopped at this point.") + .arg(title), + "evernote-import-invalid-xml"); + break; } xml.readNext(); diff --git a/src/languages/QOwnNotes_en.ts b/src/languages/QOwnNotes_en.ts index 4fa70ea8b0..4cc050f4a5 100644 --- a/src/languages/QOwnNotes_en.ts +++ b/src/languages/QOwnNotes_en.ts @@ -757,112 +757,122 @@ - + Enex files - + Select Evernote enex file to import - + + Invalid XML! + + + + + Invalid XML found in note <b>%1</b>! The import might be stopped at this point. + + + + Basic attributes - + Created date - + Updated date - + Note attributes - + Subject date - + Latitude - + Longitude - + Altitude - + Author - + Source - + Source URL - + Source application - + Reminder order - + Reminder time - + Reminder done time - + Place name - + Content class - + Application data - + Attribute - + Value