mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-09-03 21:49:13 +00:00
NOISSUE Escape quotes in paths
Just in case the user decides to place MMC in a path containing quotes. .desktop files appear to require two backslashes to escape quotes, testing on other desktop environments would be appreciated to make sure this isn't just a KDE-specific bug
This commit is contained in:
parent
08dd08afc1
commit
858487521e
@ -107,15 +107,15 @@ void CreateShortcutDialog::updateDialogState()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CreateShortcutDialog::getLaunchCommand()
|
QString CreateShortcutDialog::getLaunchCommand(bool escapeQuotesTwice)
|
||||||
{
|
{
|
||||||
return "\"" + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + "\""
|
return "\"" + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()).replace('"', escapeQuotesTwice ? "\\\\\"" : "\\\"") + "\""
|
||||||
+ getLaunchArgs();
|
+ getLaunchArgs(escapeQuotesTwice);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CreateShortcutDialog::getLaunchArgs()
|
QString CreateShortcutDialog::getLaunchArgs(bool escapeQuotesTwice)
|
||||||
{
|
{
|
||||||
return " -d \"" + QDir::toNativeSeparators(QDir::currentPath()) + "\""
|
return " -d \"" + QDir::toNativeSeparators(QDir::currentPath()).replace('"', escapeQuotesTwice ? "\\\\\"" : "\\\"") + "\""
|
||||||
+ " -l \"" + m_instance->id() + "\""
|
+ " -l \"" + m_instance->id() + "\""
|
||||||
+ (ui->joinServerCheckBox->isChecked() ? " -s \"" + ui->joinServer->text() + "\"" : "")
|
+ (ui->joinServerCheckBox->isChecked() ? " -s \"" + ui->joinServer->text() + "\"" : "")
|
||||||
+ (ui->useProfileCheckBox->isChecked() ? " -a \"" + ui->profileComboBox->currentText() + "\"" : "")
|
+ (ui->useProfileCheckBox->isChecked() ? " -a \"" + ui->profileComboBox->currentText() + "\"" : "")
|
||||||
@ -137,7 +137,7 @@ void CreateShortcutDialog::createShortcut()
|
|||||||
{
|
{
|
||||||
shortcutText = "#!/bin/sh\n"
|
shortcutText = "#!/bin/sh\n"
|
||||||
// FIXME: is there a way to use the launcher script instead of the raw binary here?
|
// FIXME: is there a way to use the launcher script instead of the raw binary here?
|
||||||
"cd \"" + QDir::currentPath() + "\"\n"
|
"cd \"" + QDir::currentPath().replace('"', "\\\"") + "\"\n"
|
||||||
+ getLaunchCommand() + " &\n";
|
+ getLaunchCommand() + " &\n";
|
||||||
} else
|
} else
|
||||||
// freedesktop.org desktop entry
|
// freedesktop.org desktop entry
|
||||||
@ -152,7 +152,7 @@ void CreateShortcutDialog::createShortcut()
|
|||||||
shortcutText = "[Desktop Entry]\n"
|
shortcutText = "[Desktop Entry]\n"
|
||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"Name=" + m_instance->name() + " - " + BuildConfig.LAUNCHER_DISPLAYNAME + "\n"
|
"Name=" + m_instance->name() + " - " + BuildConfig.LAUNCHER_DISPLAYNAME + "\n"
|
||||||
+ "Exec=" + getLaunchCommand() + "\n"
|
+ "Exec=" + getLaunchCommand(true) + "\n"
|
||||||
+ "Path=" + QDir::currentPath() + "\n"
|
+ "Path=" + QDir::currentPath() + "\n"
|
||||||
+ "Icon=" + QDir::currentPath() + "/icons/shortcut-icon.png\n";
|
+ "Icon=" + QDir::currentPath() + "/icons/shortcut-icon.png\n";
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ private:
|
|||||||
Ui::CreateShortcutDialog *ui;
|
Ui::CreateShortcutDialog *ui;
|
||||||
InstancePtr m_instance;
|
InstancePtr m_instance;
|
||||||
|
|
||||||
QString getLaunchCommand();
|
QString getLaunchCommand(bool escapeQuotesTwice = false);
|
||||||
QString getLaunchArgs();
|
QString getLaunchArgs(bool escapeQuotesTwice = false);
|
||||||
|
|
||||||
void createShortcut();
|
void createShortcut();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user