core/desktopentry: handle string escape sequences

This commit is contained in:
bbedward 2025-10-23 10:21:01 -04:00 committed by outfoxxed
parent 3e2ce40b18
commit 1b147a2c78
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 13 additions and 6 deletions

View file

@ -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.

View file

@ -269,16 +269,22 @@ QVector<QString> 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;