Merge pull request #235 from Throne3d/fix/51-prompt-before-cmd

Prompt the user before executing a command in a cmd:// URL
This commit is contained in:
Janek Bevendorff 2017-01-28 02:11:17 +02:00 committed by GitHub
commit 0116d4176a

View File

@ -497,9 +497,18 @@ void DatabaseWidget::openUrlForEntry(Entry* entry)
if (urlString.startsWith("cmd://")) { if (urlString.startsWith("cmd://")) {
if (urlString.length() > 6) { if (urlString.length() > 6) {
QMessageBox::StandardButton result;
result = MessageBox::question(
this, tr("Execute command?"),
tr("Do you really want to execute the following command?<br><br>%1")
.arg(urlString.left(200).toHtmlEscaped()),
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
QProcess::startDetached(urlString.mid(6)); QProcess::startDetached(urlString.mid(6));
} }
} }
}
else { else {
QUrl url = QUrl::fromUserInput(urlString); QUrl url = QUrl::fromUserInput(urlString);
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);