diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-04-21 21:09:17 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-04-21 21:09:17 -0300 |
commit | df9dc2cb77720b9b78ad87559657c14874d0b676 (patch) | |
tree | a4a1f2e7edcddddf24cfaf0f47818769df2ac9db /src/common | |
parent | 5f137d2c81878c41aa3b893fb56b1116bc27bc78 (diff) |
Do not allow plugins to eat Close Context
These are used for clean-up and letting them be eaten may lead to plugins getting confused about which data belong to which contexts.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/hexchat.c | 4 | ||||
-rw-r--r-- | src/common/plugin.c | 16 | ||||
-rw-r--r-- | src/common/plugin.h | 2 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/common/hexchat.c b/src/common/hexchat.c index a2e88a0d..f74fe489 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -552,7 +552,7 @@ new_ircwindow (server *serv, char *name, int type, int focus) if (user && user->hostname) set_topic (sess, user->hostname, user->hostname); } - plugin_emit_dummy_print (sess, "Open Context"); + plugin_emit_dummy_print (sess, "Open Context", -1); return sess; } @@ -629,7 +629,7 @@ session_free (session *killsess) GSList *list; int oldidx; - plugin_emit_dummy_print (killsess, "Close Context"); + plugin_emit_dummy_print (killsess, "Close Context", 0); if (current_tab == killsess) current_tab = NULL; diff --git a/src/common/plugin.c b/src/common/plugin.c index d3f3b7ca..e15e94bb 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -572,7 +572,7 @@ plugin_hook_find (GSList *list, int type, char *name) static int plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[], - hexchat_event_attrs *attrs, int type) + hexchat_event_attrs *attrs, int type, int mask) { /* fix segfault https://github.com/hexchat/hexchat/issues/2265 */ static int depth = 0; @@ -612,6 +612,8 @@ plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[], break; } + ret &= mask; + if ((ret & HEXCHAT_EAT_HEXCHAT) && (ret & HEXCHAT_EAT_PLUGIN)) { eat = 1; @@ -652,7 +654,7 @@ xit: int plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[]) { - return plugin_hook_run (sess, name, word, word_eol, NULL, HOOK_COMMAND); + return plugin_hook_run (sess, name, word, word_eol, NULL, HOOK_COMMAND, -1); } hexchat_event_attrs * @@ -678,7 +680,7 @@ plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[], attrs.server_time_utc = server_time; return plugin_hook_run (sess, name, word, word_eol, &attrs, - HOOK_SERVER | HOOK_SERVER_ATTRS); + HOOK_SERVER | HOOK_SERVER_ATTRS, -1); } /* see if any plugins are interested in this print event */ @@ -691,7 +693,7 @@ plugin_emit_print (session *sess, char *word[], time_t server_time) attrs.server_time_utc = server_time; return plugin_hook_run (sess, word[0], word, NULL, &attrs, - HOOK_PRINT | HOOK_PRINT_ATTRS); + HOOK_PRINT | HOOK_PRINT_ATTRS, -1); } /* used by plugin_emit_dummy_print to fix some UB */ @@ -707,7 +709,7 @@ check_and_invalidate(void *plug_, void *killsess_) } int -plugin_emit_dummy_print (session *sess, char *name) +plugin_emit_dummy_print (session *sess, char *name, int mask) { char *word[PDIWORDS]; int i; @@ -716,7 +718,7 @@ plugin_emit_dummy_print (session *sess, char *name) for (i = 1; i < PDIWORDS; i++) word[i] = "\000"; - i = plugin_hook_run (sess, name, word, NULL, NULL, HOOK_PRINT); + i = plugin_hook_run (sess, name, word, NULL, NULL, HOOK_PRINT, mask); /* shoehorned fix for Undefined Behaviour */ /* see https://stackoverflow.com/q/52628773/3691554 */ @@ -758,7 +760,7 @@ plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, gu for (i = 5; i < PDIWORDS; i++) word[i] = "\000"; - return plugin_hook_run (sess, word[0], word, NULL, NULL, HOOK_PRINT); + return plugin_hook_run (sess, word[0], word, NULL, NULL, HOOK_PRINT, -1); } static int diff --git a/src/common/plugin.h b/src/common/plugin.h index fb7da831..051d1f5a 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -174,7 +174,7 @@ int plugin_emit_command (session *sess, char *name, char *word[], char *word_eol int plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[], time_t server_time); int plugin_emit_print (session *sess, char *word[], time_t server_time); -int plugin_emit_dummy_print (session *sess, char *name); +int plugin_emit_dummy_print (session *sess, char *name, int mask); int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, gunichar key); GList* plugin_command_list(GList *tmp_list); int plugin_show_help (session *sess, char *cmd); |