diff --git a/src/dbus/applicationservice.cpp b/src/dbus/applicationservice.cpp index b5717c0..252cf4a 100644 --- a/src/dbus/applicationservice.cpp +++ b/src/dbus/applicationservice.cpp @@ -377,6 +377,7 @@ LaunchTask ApplicationService::unescapeExec(const QString &str, const QStringLis auto matcher = re.match(str); if (!matcher.hasMatch()) { task.command.append(std::move(execList)); + task.Resources.emplace_back(QString{""}); // mapReduce should run once at least return task; } diff --git a/src/desktopentry.cpp b/src/desktopentry.cpp index 65441f8..d0167d1 100644 --- a/src/desktopentry.cpp +++ b/src/desktopentry.cpp @@ -21,7 +21,7 @@ bool isInvalidLocaleString(const QString &str) noexcept constexpr auto Language = R"((?:[a-z]+))"; // language of locale postfix. eg.(en, zh) constexpr auto Country = R"((?:_[A-Z]+))"; // country of locale postfix. eg.(US, CN) constexpr auto Encoding = R"((?:\.[0-9A-Z-]+))"; // encoding of locale postfix. eg.(UFT-8) - constexpr auto Modifier = R"((?:@[a-z=;]+))"; // modifier of locale postfix. eg.(euro;collation=traditional) + constexpr auto Modifier = R"((?:@[a-zA-Z=;]+))"; // modifier of locale postfix. eg.(euro;collation=traditional) const static auto validKey = QString(R"(^%1%2?%3?%4?$)").arg(Language, Country, Encoding, Modifier); // example: https://regex101.com/r/hylOay/2 static const QRegularExpression _re = []() -> QRegularExpression { @@ -75,7 +75,7 @@ private: void Parser::skip() noexcept { while (!m_stream.atEnd() and (m_line.startsWith('#') or m_line.isEmpty())) { - m_line = m_stream.readLine(); + m_line = m_stream.readLine().trimmed(); } } @@ -137,6 +137,9 @@ DesktopErrorCode Parser::addGroup(Groups &ret) noexcept m_line.clear(); while (!m_stream.atEnd() && !m_line.startsWith('[')) { skip(); + if (m_line.startsWith('[')) { + break; + } auto err = addEntry(group); if (err != DesktopErrorCode::NoError) { return err; @@ -198,7 +201,12 @@ DesktopErrorCode Parser::addEntry(Groups::iterator &group) noexcept return DesktopErrorCode::NoError; } - group->insert(key, {{localeStr, valueStr}}); + if (keyIt == group->end()) { + group->insert(key, {{localeStr, valueStr}}); + return DesktopErrorCode::NoError; + } + + keyIt->insert(localeStr, valueStr); return DesktopErrorCode::NoError; } @@ -482,7 +490,9 @@ QString DesktopEntry::Value::toString(bool &ok) const noexcept { ok = false; auto str = this->find(defaultKeyStr); + if (str == this->end()) { + qWarning() << "value not found."; return {}; } diff --git a/src/global.h b/src/global.h index 7cf3130..8ac1357 100644 --- a/src/global.h +++ b/src/global.h @@ -69,10 +69,8 @@ void applyIteratively(QList dirs, T &&func) continue; } - const auto &infoList = - dir.entryInfoList({"*.desktop"}, - QDir::Readable | QDir::AllDirs | QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot, - QDir::Name | QDir::DirsLast); + const auto &infoList = dir.entryInfoList( + {"*.desktop"}, QDir::Readable | QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::DirsLast); for (const auto &info : infoList) { if (info.isFile() and func(info)) { diff --git a/tests/data/applications/deepin-editor.desktop b/tests/data/applications/deepin-editor.desktop index e8ae088..ec60459 100644 --- a/tests/data/applications/deepin-editor.desktop +++ b/tests/data/applications/deepin-editor.desktop @@ -55,7 +55,7 @@ GenericName[es]=Editor de texto GenericName[et]=Tekstiredaktor GenericName[fi]=Tekstieditori GenericName[fr]=Éditeur de texte -GenericName[en_US.UTF-8@euro;collation=traditional]=just for test\;teststing=abab\; +GenericName[en_US.UTF-8@euro]=just for test\;teststing=abab\; GenericName[gl_ES]=Editor de texto GenericName[hr]=Uređivač teksta GenericName[hu]=Szövegszerkesztő