mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replace EscapeShell with KShell::joinArgs
This commit is contained in:
parent
278ab5ebaf
commit
89879e355d
2 changed files with 8 additions and 34 deletions
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtWidgets/QSystemTrayIcon>
|
#include <QtWidgets/QSystemTrayIcon>
|
||||||
#include <QtCore/QStandardPaths>
|
#include <QtCore/QStandardPaths>
|
||||||
#include <QtCore/QProcess>
|
#include <QtCore/QProcess>
|
||||||
|
#include <KShell>
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
|
@ -172,36 +173,6 @@ void PortalAutostart(bool start, bool silent) {
|
||||||
}
|
}
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
|
||||||
QByteArray EscapeShell(const QByteArray &content) {
|
|
||||||
auto result = QByteArray();
|
|
||||||
|
|
||||||
auto b = content.constData(), e = content.constEnd();
|
|
||||||
for (auto ch = b; ch != e; ++ch) {
|
|
||||||
if (*ch == ' ' || *ch == '"' || *ch == '\'' || *ch == '\\') {
|
|
||||||
if (result.isEmpty()) {
|
|
||||||
result.reserve(content.size() * 2);
|
|
||||||
}
|
|
||||||
if (ch > b) {
|
|
||||||
result.append(b, ch - b);
|
|
||||||
}
|
|
||||||
result.append('\\');
|
|
||||||
b = ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (result.isEmpty()) {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e > b) {
|
|
||||||
result.append(b, e - b);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString EscapeShellInLauncher(const QString &content) {
|
|
||||||
return EscapeShell(content.toUtf8()).replace('\\', "\\\\");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FlatpakID() {
|
QString FlatpakID() {
|
||||||
static const auto Result = [] {
|
static const auto Result = [] {
|
||||||
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
|
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
|
||||||
|
@ -255,9 +226,12 @@ bool GenerateDesktopFile(
|
||||||
QRegularExpression(
|
QRegularExpression(
|
||||||
qsl("^Exec=telegram-desktop(.*)$"),
|
qsl("^Exec=telegram-desktop(.*)$"),
|
||||||
QRegularExpression::MultilineOption),
|
QRegularExpression::MultilineOption),
|
||||||
qsl("Exec=%1 -workdir %2\\1").arg(
|
qsl("Exec=%1\\1").arg(
|
||||||
EscapeShellInLauncher(cExeDir() + cExeName()),
|
KShell::joinArgs({
|
||||||
EscapeShellInLauncher(cWorkingDir())));
|
cExeDir() + cExeName(),
|
||||||
|
"-workdir",
|
||||||
|
cWorkingDir(),
|
||||||
|
}).replace('\\', "\\\\")));
|
||||||
|
|
||||||
fileText = fileText.replace(
|
fileText = fileText.replace(
|
||||||
QRegularExpression(
|
QRegularExpression(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit cc5550de2766657ced8d0bb4d2db3f050363d3d5
|
Subproject commit d932f5048317b05dd414116741d995c82a528542
|
Loading…
Add table
Reference in a new issue