[pim/kmail] src/editor/potentialphishingemail: Fix string case + add autotest

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 66efbf6cafbb64441bece58f9887d0fe6f9ff89f by Laurent Montel.
Committed on 28/07/2026 at 06:43.
Pushed by mlaurent into branch 'master'.

Fix string case + add autotest

M  +2    -0    src/editor/potentialphishingemail/autotests/potentialphishingemailjobtest.cpp
M  +9    -2    src/editor/potentialphishingemail/potentialphishingemailjob.cpp

https://invent.kde.org/pim/kmail/-/commit/66efbf6cafbb64441bece58f9887d0fe6f9ff89f

diff --git a/src/editor/potentialphishingemail/autotests/potentialphishingemailjobtest.cpp b/src/editor/potentialphishingemail/autotests/potentialphishingemailjobtest.cpp
index f1ceff0fd..4d4bfb691 100644
--- a/src/editor/potentialphishingemail/autotests/potentialphishingemailjobtest.cpp
+++ b/src/editor/potentialphishingemail/autotests/potentialphishingemailjobtest.cpp
@@ -34,6 +34,8 @@ void PotentialPhishingEmailJobTest::shouldReturnPotentialPhishingEmails_data()
     QTest::newRow("HasPotentialPhishing") << (QStringList() << QStringLiteral("\"[email protected]\" <[email protected]>")) << QStringList() << true;
     const QString email = QStringLiteral("\"[email protected]\" <[email protected]>");
     QTest::newRow("EmailInWhiteList") << (QStringList() << email) << (QStringList() << email) << false;
+    QTest::newRow("EmailInWhiteListCaseInsensitive") << (QStringList() << QStringLiteral("\"[email protected]\" <[email protected]>"))
+                                                     << (QStringList() << QStringLiteral("\"[email protected]\" <[email protected]>")) << false;
     QTest::newRow("NotAllEmailInWhiteList") << (QStringList() << email << QStringLiteral("\"[email protected]\" <[email protected]>")) << (QStringList() << email) << true;
     QTest::newRow("EmailInWhiteListWithSpace") << (QStringList() << QStringLiteral(" \"[email protected]\" <[email protected]> ")) << (QStringList() << email) << false;
     QTest::newRow("EmailWithSameNameAndDisplayName") << (QStringList() << QStringLiteral("\"<[email protected]>\" <[email protected]>")) << (QStringList() << email)
diff --git a/src/editor/potentialphishingemail/potentialphishingemailjob.cpp b/src/editor/potentialphishingemail/potentialphishingemailjob.cpp
index b9c6c049e..645f09079 100644
--- a/src/editor/potentialphishingemail/potentialphishingemailjob.cpp
+++ b/src/editor/potentialphishingemail/potentialphishingemailjob.cpp
@@ -18,7 +18,14 @@ PotentialPhishingEmailJob::~PotentialPhishingEmailJob() = default;
 
 void PotentialPhishingEmailJob::setEmailWhiteList(const QStringList &emails)
 {
-    mEmailWhiteList = emails;
+    mEmailWhiteList.clear();
+    mEmailWhiteList.reserve(emails.count());
+    for (const QString &email : emails) {
+        const QString normalizedEmail = email.trimmed().toCaseFolded();
+        if (!normalizedEmail.isEmpty()) {
+            mEmailWhiteList.append(normalizedEmail);
+        }
+    }
 }
 
 void PotentialPhishingEmailJob::setPotentialPhishingEmails(const QStringList &list)
@@ -52,7 +59,7 @@ bool PotentialPhishingEmailJob::start()
         return false;
     }
     for (const QString &addr : std::as_const(mEmails)) {
-        if (!mEmailWhiteList.contains(addr.trimmed())) {
+        if (!mEmailWhiteList.contains(addr.trimmed().toCaseFolded())) {
             QString tname;
             QString temail;
             KEmailAddress::extractEmailAddressAndName(addr, temail, tname); // ignore return value
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.