diff --git a/src/cfgparse.y b/src/cfgparse.y index 5b2b4b5c..10ca48cc 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -659,6 +659,10 @@ bindsym: for_window: TOK_FOR_WINDOW match command { + if (match_is_empty(¤t_match)) { + ELOG("Match is empty, ignoring this for_window statement\n"); + break; + } printf("\t should execute command %s for the criteria mentioned above\n", $3); Assignment *assignment = scalloc(sizeof(Assignment)); assignment->type = A_COMMAND; diff --git a/testcases/t/65-for_window.t b/testcases/t/65-for_window.t index 2fb85dfa..fb4c2812 100644 --- a/testcases/t/65-for_window.t +++ b/testcases/t/65-for_window.t @@ -313,4 +313,41 @@ is($content[0]->{border}, 'none', 'no border'); exit_gracefully($process->pid); +############################################################## +# 7: check that invalid criteria don’t end up matching all windows +############################################################## + +# this configuration is broken because "asdf" is not a valid integer +# the for_window should therefore recognize this error and don’t add the +# assignment +$config = <root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30 ], + background_color => '#00ff00', +); + +$window->_create; + +set_wm_class($window->id, 'bar', 'foo'); +$window->name('usethis'); +$window->map; +sleep 0.25; + +@content = @{get_ws_content($tmp)}; +cmp_ok(@content, '==', 1, 'one node on this workspace now'); +is($content[0]->{border}, 'normal', 'normal border'); + +exit_gracefully($process->pid); + + done_testing;