[pim/kmail] src: Fix typo + add autotest

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

Fix typo + add autotest

M  +10   -0    src/autotests/commandlineinfotest.cpp
M  +1    -1    src/commandlineinfo.cpp

https://invent.kde.org/pim/kmail/-/commit/9f40a005efa1dad84e80f17c1b0ee6119324dcd2

diff --git a/src/autotests/commandlineinfotest.cpp b/src/autotests/commandlineinfotest.cpp
index 4ade2bc02..1d853a28b 100644
--- a/src/autotests/commandlineinfotest.cpp
+++ b/src/autotests/commandlineinfotest.cpp
@@ -63,6 +63,16 @@ void CommandLineInfoTest::parseCommandLineInfo_data()
         info.setMailto(true);
         QTest::newRow("test1") << args << QString() << info;
     }
+    {
+        QStringList args;
+        args << QStringLiteral("kmail");
+        args << QStringLiteral("mailto:[email protected]?body=one&two=three");
+        CommandLineInfo info;
+        info.setTo(QStringLiteral("[email protected]"));
+        info.setBody(QStringLiteral("one&two=three"));
+        info.setMailto(true);
+        QTest::newRow("mailto body keeps unknown fragments") << args << QString() << info;
+    }
 }
 
 void CommandLineInfoTest::parseCommandLineInfo()
diff --git a/src/commandlineinfo.cpp b/src/commandlineinfo.cpp
index c811b0bc5..56be8478c 100644
--- a/src/commandlineinfo.cpp
+++ b/src/commandlineinfo.cpp
@@ -199,7 +199,7 @@ void CommandLineInfo::parseCommandLine(const QStringList &args, const QString &w
                         // Workaround: https://bugs.kde.org/show_bug.cgi?id=390939
                         // QMap<QString, QString> parseMailtoUrl(const QUrl &url) parses correctly url
                         // But if we have a "&" unknown key we lost it.
-                        if (previousKey == "mBody"_L1) {
+                        if (previousKey == "body"_L1) {
                             mBody += QLatin1Char('&') + key + QLatin1Char('=') + element.second;
                         }
                         // Don't clear previous key.
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.