core/desktopentry: trim lines in desktop entries when parsing

This commit is contained in:
2 * r + 2 * t authored and outfoxxed committed 2026-10-16 17:59:45 -07:00
1 parent 4befab5bc6
commit 30a5d60a31
2 files changed
+8 -6

No files matched your search

+1
View File
@@ -2,3 +2,4 @@
- Fixed ScriptModel not sending role updates on changed data that compares equal by key or structure.
- Fixed Hyprland workspaces keeping their old id after Hyprland changes it.
- Fixed desktop entries being parsed incorrectly with trailing whitespace or CRLF line endings.
+7 -6
View File
@@ -158,22 +158,23 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString&
};
for (auto& line: text.split(u'\n', Qt::SkipEmptyParts)) {
if (line.startsWith(u'#')) continue;
const auto trimmed = line.trimmed();
if (trimmed.isEmpty() || trimmed.startsWith(u'#')) continue;
if (line.startsWith(u'[') && line.endsWith(u']')) {
if (trimmed.startsWith(u'[') && trimmed.endsWith(u']')) {
finishCategory();
groupName = line.sliced(1, line.length() - 2);
groupName = trimmed.sliced(1, trimmed.length() - 2);
continue;
}
auto splitIdx = line.indexOf(u'=');
auto splitIdx = trimmed.indexOf(u'=');
if (splitIdx == -1) {
qCWarning(logDesktopEntry) << "Encountered invalid line in desktop entry (no =)" << line;
continue;
}
auto key = line.sliced(0, splitIdx);
const auto& value = line.sliced(splitIdx + 1);
auto key = trimmed.sliced(0, splitIdx);
const auto& value = trimmed.sliced(splitIdx + 1);
auto localeIdx = key.indexOf('[');
Locale locale;