Wayland support and prevent Klipper from saving passwords:

- Use KSystemClipboard instead of QClipper to make krunner-pass work
    under wayland.
  - Specify the "x-kde-passwordManagerHint" mimetype when copying the
    password to the clipboard to prevent Klipper from storing the
    plaintext password in the history.
master^2
Robert Buhren 3 years ago
parent e3ae5484a3
commit 88de11ff3c
  1. 5
      CMakeLists.txt
  2. 14
      pass.cpp

@ -25,8 +25,8 @@ find_package (KF5 ${KF5_MIN_VERSION}
Notifications Notifications
Auth Auth
KCMUtils KCMUtils
GuiAddons
) )
include(KDEInstallDirs) include(KDEInstallDirs)
include(KDECMakeSettings) include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECompilerSettings NO_POLICY_SCOPE)
@ -73,7 +73,8 @@ target_link_libraries(krunner_pass KF5::Runner Qt5::Widgets
KF5::Service KF5::Service
KF5::Plasma KF5::Plasma
KF5::ConfigWidgets KF5::ConfigWidgets
KF5::Notifications) KF5::Notifications
KF5::GuiAddons)
add_dependencies(krunner_pass kcm_krunner_pass) add_dependencies(krunner_pass kcm_krunner_pass)

@ -26,6 +26,8 @@
#include <QTimer> #include <QTimer>
#include <QMessageBox> #include <QMessageBox>
#include <QClipboard> #include <QClipboard>
#include <KSystemClipboard>
#include <QMimeData>
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
@ -185,10 +187,14 @@ void Pass::match(Plasma::RunnerContext &context)
void Pass::clip(const QString &msg) void Pass::clip(const QString &msg)
{ {
QClipboard *cb = QApplication::clipboard(); auto md = new QMimeData;
cb->setText(msg); auto kc = KSystemClipboard::instance();
QTimer::singleShot(timeout * 1000, cb, [cb]() { // https://phabricator.kde.org/D12539
cb->setText(QString()); md->setText(msg);
md->setData(QStringLiteral("x-kde-passwordManagerHint"), "secret");
kc->setMimeData(md,QClipboard::Clipboard);
QTimer::singleShot(timeout * 1000, kc, [kc]() {
kc->clear(QClipboard::Clipboard);
}); });
} }

Loading…
Cancel
Save