mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-09-22 05:44:46 -04:00
Add safeguards to secure input on macOS (#11928)
* Add safeguards to secure input on macOS * Fixes #11906 * Disable secure input when password widget is hidden as well as focused out * Add safeguard to ensure the internal counter that macOS keeps is always set to 1 preventing the ability to disable secure input by focus/unfocus a password field
This commit is contained in:
parent
8a32b3bc5e
commit
f32ed71dfc
2 changed files with 12 additions and 1 deletions
|
@ -231,7 +231,7 @@ bool PasswordWidget::eventFilter(QObject* watched, QEvent* event)
|
|||
if (isVisible() && (type == QEvent::KeyPress || type == QEvent::KeyRelease || type == QEvent::FocusIn)) {
|
||||
checkCapslockState();
|
||||
}
|
||||
if (type == QEvent::FocusIn || type == QEvent::FocusOut) {
|
||||
if (type == QEvent::FocusIn || type == QEvent::FocusOut || type == QEvent::Hide) {
|
||||
osUtils->setUserInputProtection(type == QEvent::FocusIn);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,11 +152,22 @@ bool MacUtils::isCapslockEnabled()
|
|||
|
||||
void MacUtils::setUserInputProtection(bool enable)
|
||||
{
|
||||
static bool secureInputEnabled = false;
|
||||
if (enable) {
|
||||
/*
|
||||
* MacOS keeps a single counter over all apps that needs to be zero to disable secure input. By never going
|
||||
* higher than 1 internally this makes sure secure input doesn't stay active after calling this function
|
||||
* multiple times.
|
||||
*/
|
||||
if (secureInputEnabled) {
|
||||
DisableSecureEventInput();
|
||||
}
|
||||
EnableSecureEventInput();
|
||||
} else {
|
||||
DisableSecureEventInput();
|
||||
}
|
||||
// Store our last known state
|
||||
secureInputEnabled = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue