Skip to content

Commit 0e78bec

Browse files
committed
core/desktopentry: handle string escape sequences
1 parent 3e2ce40 commit 0e78bec

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/core/desktopentry.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,22 @@ QVector<QString> DesktopEntry::parseExecString(const QString& execString) {
270270
escape = 0;
271271
}
272272
} else if (escape != 0) {
273-
if (escape != 2) {
274-
// Technically this is an illegal state, but the spec has a terrible double escape
275-
// rule in strings for no discernable reason. Assuming someone might understandably
276-
// misunderstand it, treat it as a normal escape and log it.
277-
qCWarning(logDesktopEntry).noquote()
278-
<< "Illegal escape sequence in desktop entry exec string:" << execString;
273+
if (escape == 2) {
274+
currentArgument += c;
275+
} else {
276+
switch (c.unicode()) {
277+
case 's': currentArgument += u' '; break;
278+
case 'n': currentArgument += u'\n'; break;
279+
case 't': currentArgument += u'\t'; break;
280+
case 'r': currentArgument += u'\r'; break;
281+
case '\\': currentArgument += u'\\'; break;
282+
default:
283+
qCWarning(logDesktopEntry).noquote()
284+
<< "Illegal escape sequence in desktop entry exec string:" << execString;
285+
currentArgument += c;
286+
break;
287+
}
279288
}
280-
281-
currentArgument += c;
282289
escape = 0;
283290
} else if (c == u'"' || c == u'\'') {
284291
parsingString = false;

0 commit comments

Comments
 (0)