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
Auth
KCMUtils
GuiAddons
)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
@ -73,7 +73,8 @@ target_link_libraries(krunner_pass KF5::Runner Qt5::Widgets
KF5::Service
KF5::Plasma
KF5::ConfigWidgets
KF5::Notifications)
KF5::Notifications
KF5::GuiAddons)
add_dependencies(krunner_pass kcm_krunner_pass)

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