diff --git a/autotests/desktoptojsontest.cpp b/autotests/desktoptojsontest.cpp --- a/autotests/desktoptojsontest.cpp +++ b/autotests/desktoptojsontest.cpp @@ -163,7 +163,7 @@ // test conversion of a currently existing .desktop file (excluding most of the translations): QByteArray kdevInput = "[Desktop Entry]\n" - "Type=Service\n" + "Type = Service\n" "Icon=text-x-c++src\n" "Exec=blubb\n" "Comment=C/C++ Language Support\n" @@ -276,7 +276,7 @@ // test conversion of kcookiejar.desktop (for some reason the wrong boolean values were committed) QByteArray kcookiejarInput = "[Desktop Entry]\n" - "Type=Service\n" + "Type= Service\n" "Name=Cookie Jar\n" "Comment=Stores network cookies\n" "X-KDE-ServiceTypes=KDEDModule\n" diff --git a/src/lib/plugin/desktopfileparser.cpp b/src/lib/plugin/desktopfileparser.cpp --- a/src/lib/plugin/desktopfileparser.cpp +++ b/src/lib/plugin/desktopfileparser.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include // in the desktoptojson binary enable debug messages by default, in the library only warning messages #ifdef BUILDING_DESKTOPTOJSON_TOOL @@ -226,9 +228,12 @@ *nextGroup = name; break; } - if (line.startsWith(QByteArrayLiteral("Type="))) { - // TODO: should we also have to accept spaces around equals here? - type = line.mid(qstrlen("Type=")); + + const static QRegularExpression typeEntryRegex( + QStringLiteral("^Type\\s*=\\s*(.*)$")); + const auto match = typeEntryRegex.match(QString::fromUtf8(line)); + if (match.hasMatch()) { + type = match.captured(1).toUtf8(); } } return type;