swallow: fix invalid regexes with empty vals

This commit is contained in:
vaxerski 2023-04-15 19:15:59 +01:00
parent 4c4fcc128b
commit 8944db49be

View file

@ -509,7 +509,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
} }
// verify swallowing // verify swallowing
if (*PSWALLOW) { if (*PSWALLOW && *PSWALLOWREGEX != STRVAL_EMPTY) {
// don't swallow ourselves // don't swallow ourselves
std::regex rgx(*PSWALLOWREGEX); std::regex rgx(*PSWALLOWREGEX);
if (!std::regex_match(g_pXWaylandManager->getAppIDClass(PWINDOW), rgx)) { if (!std::regex_match(g_pXWaylandManager->getAppIDClass(PWINDOW), rgx)) {
@ -554,10 +554,16 @@ void Events::listener_mapWindow(void* owner, void* data) {
} }
if (finalFound) { if (finalFound) {
bool valid = std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx);
if (*PSWALLOWEXREGEX != STRVAL_EMPTY) {
std::regex exc(*PSWALLOWEXREGEX); std::regex exc(*PSWALLOWEXREGEX);
valid = valid && !std::regex_match(g_pXWaylandManager->getTitle(finalFound), exc);
}
// check if it's the window we want & not exempt from getting swallowed // check if it's the window we want & not exempt from getting swallowed
if (std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx) && if (valid) {
!std::regex_match(g_pXWaylandManager->getTitle(finalFound), exc)) {
// swallow // swallow
PWINDOW->m_pSwallowed = finalFound; PWINDOW->m_pSwallowed = finalFound;