mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01: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:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user