mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-12-05 14:31:49 +00:00
fix issue 454 and 468
This commit is contained in:
4 files changed
+54
-18
No files matched your search
@@ -285,13 +285,15 @@ char *decrypt_raw_message(const char *message, const char *key) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean have_echo_message(void) {
|
||||
return g_strcmp0(zoitechat_get_info(ph, "echo-message"), "1") == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a message is to be sent.
|
||||
*/
|
||||
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||
char *prefix;
|
||||
enum fish_mode mode;
|
||||
char *message;
|
||||
GString *command;
|
||||
GSList *encrypted_list, *encrypted_item;
|
||||
|
||||
@@ -309,15 +311,15 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_NONE;
|
||||
}
|
||||
|
||||
/* Get prefix for own nick if any */
|
||||
prefix = get_my_own_prefix();
|
||||
/* Let the decrypted server echo display the message when available. */
|
||||
if (!have_echo_message()) {
|
||||
char *prefix = get_my_own_prefix();
|
||||
char *message = g_strconcat("[", fish_modes[mode], "] ", word_eol[1], NULL);
|
||||
|
||||
/* Add encrypted flag */
|
||||
message = g_strconcat("[", fish_modes[mode], "] ", word_eol[1], NULL);
|
||||
|
||||
/* Display message */
|
||||
zoitechat_emit_print(ph, "Your Message", zoitechat_get_info(ph, "nick"), message, prefix, NULL);
|
||||
g_free(message);
|
||||
zoitechat_emit_print(ph, "Your Message", zoitechat_get_info(ph, "nick"), message, prefix, NULL);
|
||||
g_free(message);
|
||||
g_free(prefix);
|
||||
}
|
||||
|
||||
/* Send encrypted messages */
|
||||
encrypted_item = encrypted_list;
|
||||
@@ -328,7 +330,6 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||
encrypted_item = encrypted_item->next;
|
||||
}
|
||||
|
||||
g_free(prefix);
|
||||
g_string_free(command, TRUE);
|
||||
g_slist_free_full(encrypted_list, g_free);
|
||||
|
||||
@@ -412,6 +413,14 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_NONE;
|
||||
|
||||
sender = irc_prefix_get_nick(prefix);
|
||||
/* A reflected outgoing key exchange is not a request from the peer. */
|
||||
if (irc_nick_cmp(sender, zoitechat_get_info(ph, "nick")) == 0 &&
|
||||
irc_nick_cmp(word[3], sender) != 0 &&
|
||||
(!strcmp(dh_message, ":DH1080_INIT") || !strcmp(dh_message, ":DH1080_FINISH"))) {
|
||||
g_free(sender);
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
}
|
||||
|
||||
query_ctx = find_context_on_network(sender);
|
||||
if (query_ctx)
|
||||
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
||||
@@ -950,7 +959,6 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
|
||||
static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
const char *target = word[2];
|
||||
const char *notice = word_eol[3];
|
||||
char *notice_flag;
|
||||
enum fish_mode mode;
|
||||
GString *command;
|
||||
GSList *encrypted_list, *encrypted_item;
|
||||
@@ -976,8 +984,11 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
}
|
||||
|
||||
notice_flag = g_strconcat("[", fish_modes[mode], "] ", notice, NULL);
|
||||
zoitechat_emit_print(ph, "Notice Send", target, notice_flag);
|
||||
if (!have_echo_message()) {
|
||||
char *notice_flag = g_strconcat("[", fish_modes[mode], "] ", notice, NULL);
|
||||
zoitechat_emit_print(ph, "Notice Send", target, notice_flag);
|
||||
g_free(notice_flag);
|
||||
}
|
||||
|
||||
/* Send encrypted messages */
|
||||
encrypted_item = encrypted_list;
|
||||
@@ -987,7 +998,6 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
encrypted_item = encrypted_item->next;
|
||||
}
|
||||
|
||||
g_free(notice_flag);
|
||||
g_string_free(command, TRUE);
|
||||
g_slist_free_full(encrypted_list, g_free);
|
||||
|
||||
@@ -1039,6 +1049,9 @@ static int handle_crypt_msg(char *word[], char *word_eol[], void *userdata) {
|
||||
g_string_free(command, TRUE);
|
||||
g_slist_free_full(encrypted_list, g_free);
|
||||
|
||||
if (have_echo_message())
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
|
||||
query_ctx = find_context_on_network(target);
|
||||
if (query_ctx) {
|
||||
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
||||
@@ -1079,7 +1092,8 @@ static int handle_crypt_me(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
}
|
||||
|
||||
zoitechat_emit_print(ph, "Your Action", zoitechat_get_info(ph, "nick"), word_eol[2], NULL);
|
||||
if (!have_echo_message())
|
||||
zoitechat_emit_print(ph, "Your Action", zoitechat_get_info(ph, "nick"), word_eol[2], NULL);
|
||||
|
||||
/* Send encrypted messages */
|
||||
encrypted_item = encrypted_list;
|
||||
|
||||
Reference in new issue
Block a user