Skip to content

Commit f36322d

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

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/core/desktopentry.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,22 @@ QVector<QString> DesktopEntry::parseExecString(const QString& execString) {
269269
currentArgument += '\\';
270270
escape = 0;
271271
}
272+
} else if (escape == 2) {
273+
currentArgument += c;
274+
escape = 0;
272275
} 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.
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:
277283
qCWarning(logDesktopEntry).noquote()
278284
<< "Illegal escape sequence in desktop entry exec string:" << execString;
285+
currentArgument += c;
286+
break;
279287
}
280-
281-
currentArgument += c;
282288
escape = 0;
283289
} else if (c == u'"' || c == u'\'') {
284290
parsingString = false;

0 commit comments

Comments
 (0)