NOISSUE prevent -version being passed to the JRE

We want specific JREs, always, not something that is magically resolved.
This counteracts some really bad advice recently being spread on reddit.
This commit is contained in:
Petr Mrázek 2022-04-06 22:45:57 +02:00
parent e4d8ae582d
commit 6afff3e31f
3 changed files with 15 additions and 2 deletions

View File

@ -17,6 +17,17 @@ bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
QMessageBox::Warning)->exec();
return false;
}
// block lunacy with passing required version to the JVM
if (jvmargs.contains(QRegExp("-version:.*"))) {
auto warnStr = QObject::tr(
"You tried to pass required java version argument to the JVM (using \"-version=xxx\"). This is not safe and will not be allowed.\n"
"This message will be displayed until you remove this from the JVM arguments.");
CustomMessageBox::selectable(
parent, QObject::tr("JVM arguments warning"),
warnStr,
QMessageBox::Warning)->exec();
return false;
}
return true;
}

View File

@ -36,7 +36,10 @@ void LaunchController::executeTask()
return;
}
JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
if(!JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget)) {
emitFailed(tr("Invalid Java arguments specified. Please fix this first."));
return;
}
login();
}

View File

@ -141,7 +141,6 @@ void InstanceSettingsPage::applySettings()
if(javaArgs)
{
m_settings->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " "));
JavaCommon::checkJVMArgs(m_settings->get("JvmArgs").toString(), this->parentWidget());
}
else
{