mirror of
https://github.com/hyprwm/hyprlock.git
synced 2026-05-19 19:28:08 +02:00
Fixed an issue, where control characters could accidentaly enter passBuffer.
Changed one condition for consistency with rest of the code (m_sPasswordState.passBuffer.length()>0 -> !m_sPasswordState.passBuffer.empty()) Fix for issue #982
This commit is contained in:
parent
24c66d1be8
commit
12769ec42d
1 changed files with 6 additions and 2 deletions
|
|
@ -614,6 +614,8 @@ void CHyprlock::onKey(uint32_t key, bool down) {
|
|||
renderAllOutputs();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CHyprlock::handleKeySym(xkb_keysym_t sym, bool composed) {
|
||||
const auto SYM = sym;
|
||||
|
||||
|
|
@ -632,8 +634,10 @@ void CHyprlock::handleKeySym(xkb_keysym_t sym, bool composed) {
|
|||
}
|
||||
|
||||
g_pAuth->submitInput(m_sPasswordState.passBuffer);
|
||||
return;
|
||||
|
||||
} else if (SYM == XKB_KEY_BackSpace || SYM == XKB_KEY_Delete) {
|
||||
if (m_sPasswordState.passBuffer.length() > 0) {
|
||||
if ( !m_sPasswordState.passBuffer.empty() ) {
|
||||
// handle utf-8
|
||||
while ((m_sPasswordState.passBuffer.back() & 0xc0) == 0x80)
|
||||
m_sPasswordState.passBuffer.pop_back();
|
||||
|
|
@ -648,7 +652,7 @@ void CHyprlock::handleKeySym(xkb_keysym_t sym, bool composed) {
|
|||
int len = (composed) ? xkb_compose_state_get_utf8(g_pSeatManager->m_pXKBComposeState, buf, sizeof(buf)) /* nullbyte */ + 1 :
|
||||
xkb_keysym_to_utf8(SYM, buf, sizeof(buf)) /* already includes a nullbyte */;
|
||||
|
||||
if (len > 1)
|
||||
if (len > 1 && buf[0]>=0x20) // Control character don't have any bussiness being in the password
|
||||
m_sPasswordState.passBuffer += std::string{buf, len - 1};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue