[pim/ktnef] src: Only return vCard data if there's actually anything in it

Volker Krause <[email protected]> Tue, 4 Aug 2026 17:03:37 +0000 (UTC)
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit fd12601cae706aa6dcde8b2a876e32c736d54ae1 by Volker Krause.
Committed on 04/08/2026 at 16:55.
Pushed by vkrause into branch 'master'.

Only return vCard data if there's actually anything in it

This is a bit crude, but given the hundred of properties here this is the
easiest way to check for emptyness. (KContacts::Addressee::isEmpty is
misleading, that returns false after any setter is called with an empty
value already).

M  +6    -1    src/formatter.cpp

https://invent.kde.org/pim/ktnef/-/commit/fd12601cae706aa6dcde8b2a876e32c736d54ae1

diff --git a/src/formatter.cpp b/src/formatter.cpp
index 66376fb..071efa0 100644
--- a/src/formatter.cpp
+++ b/src/formatter.cpp
@@ -414,7 +414,12 @@ QByteArray KTnef::messageToVcard(const KTNEFMessage *tnefMsg)
 
             // bOk = (!addressee.isEmpty());
             KContacts::VCardConverter converter;
-            return converter.createVCard(addressee);
+            auto vcard = converter.createVCard(addressee);
+            if (std::ranges::any_of(converter.parseVCards(vcard), [](const KContacts::Addressee &a) {
+                    return !a.isEmpty();
+                })) {
+                return vcard;
+            }
         }
     }