Prevent Klipper from storing secrets in clipboard history (#1969)

This commit is contained in:
TheZ3ro 2018-08-29 17:13:55 +02:00 committed by Jonathan White
parent ca27fb06d5
commit 08a36b4d40
2 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,5 @@
/*
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
@ -19,6 +20,7 @@
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
#include <QTimer>
#include "core/Config.h"
@ -46,15 +48,20 @@ void Clipboard::setText(const QString& text)
{
QClipboard* clipboard = QApplication::clipboard();
#ifdef Q_OS_MAC
QMimeData* mime = new QMimeData;
#ifdef Q_OS_MAC
mime->setText(text);
mime->setData("application/x-nspasteboard-concealed-type", text.toUtf8());
clipboard->setMimeData(mime, QClipboard::Clipboard);
#else
clipboard->setText(text, QClipboard::Clipboard);
const QString secretStr = "secret";
QByteArray secretBa = secretStr.toUtf8();
mime->setText(text);
mime->setData("x-kde-passwordManagerHint", secretBa);
clipboard->setMimeData(mime, QClipboard::Clipboard);
if (clipboard->supportsSelection()) {
clipboard->setText(text, QClipboard::Selection);
clipboard->setMimeData(mime, QClipboard::Selection);
}
#endif

View File

@ -1,4 +1,5 @@
/*
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify