diff options
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 811e560..b9c819b 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -675,6 +675,18 @@ public: | |||
675 | } | 675 | } |
676 | } | 676 | } |
677 | 677 | ||
678 | static bool validateContent(const QByteArray &data) { | ||
679 | if (data.isEmpty()) { | ||
680 | SinkError() << "No data available."; | ||
681 | return false; | ||
682 | } | ||
683 | if (data.contains('\0')) { | ||
684 | SinkError() << "Data contains NUL, this will fail with IMAP."; | ||
685 | return false; | ||
686 | } | ||
687 | return true; | ||
688 | } | ||
689 | |||
678 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE | 690 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE |
679 | { | 691 | { |
680 | if (operation != Sink::Operation_Creation) { | 692 | if (operation != Sink::Operation_Creation) { |
@@ -692,6 +704,9 @@ public: | |||
692 | if (operation == Sink::Operation_Creation) { | 704 | if (operation == Sink::Operation_Creation) { |
693 | const QString mailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, mail.getFolder()); | 705 | const QString mailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, mail.getFolder()); |
694 | const auto content = ensureCRLF(mail.getMimeMessage()); | 706 | const auto content = ensureCRLF(mail.getMimeMessage()); |
707 | if (!validateContent(content)) { | ||
708 | SinkError() << "Validation failed during creation replay " << mail.identifier() << "\n Content:" << content; | ||
709 | } | ||
695 | const auto flags = getFlags(mail); | 710 | const auto flags = getFlags(mail); |
696 | const QDateTime internalDate = mail.getDate(); | 711 | const QDateTime internalDate = mail.getDate(); |
697 | job = login.then(imap->append(mailbox, content, flags, internalDate)) | 712 | job = login.then(imap->append(mailbox, content, flags, internalDate)) |
@@ -727,6 +742,9 @@ public: | |||
727 | const auto folderId = folderIdFromMailRid(oldRemoteId); | 742 | const auto folderId = folderIdFromMailRid(oldRemoteId); |
728 | const QString oldMailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId); | 743 | const QString oldMailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId); |
729 | const auto content = ensureCRLF(mail.getMimeMessage()); | 744 | const auto content = ensureCRLF(mail.getMimeMessage()); |
745 | if (!validateContent(content)) { | ||
746 | SinkError() << "Validation failed during modification replay " << mail.identifier() << "\n Content:" << content; | ||
747 | } | ||
730 | const QDateTime internalDate = mail.getDate(); | 748 | const QDateTime internalDate = mail.getDate(); |
731 | SinkTrace() << "Replacing message. Old mailbox: " << oldMailbox << "New mailbox: " << mailbox << "Flags: " << flags << "Content: " << content; | 749 | SinkTrace() << "Replacing message. Old mailbox: " << oldMailbox << "New mailbox: " << mailbox << "Flags: " << flags << "Content: " << content; |
732 | KIMAP2::ImapSet set; | 750 | KIMAP2::ImapSet set; |