Skip to content

Commit

Permalink
[ui] add security warning to the plugin manager's install from ZIP
Browse files Browse the repository at this point in the history
(cherry-picked from 683df59)
  • Loading branch information
nirvn authored and nyalldawson committed Aug 21, 2018
1 parent 6c3f9b4 commit f198c11
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/app/pluginmanager/qgspluginmanager.cpp
Expand Up @@ -30,6 +30,7 @@
#include <QTextStream>
#include <QTimer>
#include <QDesktopServices>
#include <QCheckBox>

#include "qgis.h"
#include "qgisapp.h"
Expand Down Expand Up @@ -1367,8 +1368,28 @@ void QgsPluginManager::mZipFileWidget_fileChanged( const QString &filePath )

void QgsPluginManager::buttonInstallFromZip_clicked()
{
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().installFromZipFile(r'%1')" ).arg( mZipFileWidget->filePath() ) );
mZipFileWidget->setFilePath( "" );
QgsSettings settings;
bool showInstallFromZipWarning = settings.value( QStringLiteral( "UI/showInstallFromZipWarning" ), true ).toBool();

QMessageBox msgbox;
if ( showInstallFromZipWarning )
{
msgbox.setText( tr( "Security warning: installing a plugin from an untrusted source can lead to data loss and/or leak. Continue?" ) );
msgbox.setIcon( QMessageBox::Icon::Warning );
msgbox.addButton( QMessageBox::Yes );
msgbox.addButton( QMessageBox::No );
msgbox.setDefaultButton( QMessageBox::No );
QCheckBox *cb = new QCheckBox( tr( "Don't show this again." ) );
msgbox.setCheckBox( cb );
msgbox.exec();
settings.setValue( QStringLiteral( "UI/showInstallFromZipWarning" ), !msgbox.checkBox()->isChecked() );
}

if ( !showInstallFromZipWarning || msgbox.result() == QMessageBox::Yes )
{
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().installFromZipFile(r'%1')" ).arg( mZipFileWidget->filePath() ) );
mZipFileWidget->setFilePath( "" );
}
}


Expand Down

0 comments on commit f198c11

Please sign in to comment.