From 1b147a2c78983877909f9e531fc8ce17c35a297a Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 23 Oct 2025 10:21:01 -0400 Subject: [PATCH] core/desktopentry: handle string escape sequences --- changelog/next.md | 1 + src/core/desktopentry.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/changelog/next.md b/changelog/next.md index 93d1f2f..543f9e2 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -22,3 +22,4 @@ set shell id. ## Bug Fixes - Fixed volume control breaking with pipewire pro audio mode. +- Fixed escape sequence handling in desktop entries. diff --git a/src/core/desktopentry.cpp b/src/core/desktopentry.cpp index 941a405..2dbafea 100644 --- a/src/core/desktopentry.cpp +++ b/src/core/desktopentry.cpp @@ -269,16 +269,22 @@ QVector DesktopEntry::parseExecString(const QString& execString) { currentArgument += '\\'; escape = 0; } + } else if (escape == 2) { + currentArgument += c; + escape = 0; } else if (escape != 0) { - if (escape != 2) { - // Technically this is an illegal state, but the spec has a terrible double escape - // rule in strings for no discernable reason. Assuming someone might understandably - // misunderstand it, treat it as a normal escape and log it. + switch (c.unicode()) { + case 's': currentArgument += u' '; break; + case 'n': currentArgument += u'\n'; break; + case 't': currentArgument += u'\t'; break; + case 'r': currentArgument += u'\r'; break; + case '\\': currentArgument += u'\\'; break; + default: qCWarning(logDesktopEntry).noquote() << "Illegal escape sequence in desktop entry exec string:" << execString; + currentArgument += c; + break; } - - currentArgument += c; escape = 0; } else if (c == u'"' || c == u'\'') { parsingString = false;