diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2015-10-02 11:48:11 +0200 |
---|---|---|
committer | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2015-10-02 11:48:11 +0200 |
commit | acbe2ecac299d4f6770c60747776cbea290bee3f (patch) | |
tree | 78401fb48860c896847837164bb226bdfc66d202 | |
parent | 8217147a805af081010578b0dcd7fe42fede1425 (diff) | |
parent | cfff402fe677316d286ce6663b8afeee4be95526 (diff) | |
download | irssi-acbe2ecac299d4f6770c60747776cbea290bee3f.zip |
Merge pull request #315 from LemonBoy/prevent_blank_usermode
Don't set the usermode field if blank
-rw-r--r-- | src/irc/core/irc-chatnets.c | 5 | ||||
-rw-r--r-- | src/irc/core/irc-servers-setup.c | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/irc/core/irc-chatnets.c b/src/irc/core/irc-chatnets.c index d72f71dd..0796e0cb 100644 --- a/src/irc/core/irc-chatnets.c +++ b/src/irc/core/irc-chatnets.c @@ -35,10 +35,13 @@ void ircnet_create(IRC_CHATNET_REC *rec) static void sig_chatnet_read(IRC_CHATNET_REC *rec, CONFIG_NODE *node) { + char *value; + if (!IS_IRC_CHATNET(rec)) return; - rec->usermode = g_strdup(config_node_get_str(node, "usermode", NULL)); + value = config_node_get_str(node, "usermode", NULL); + rec->usermode = (value != NULL && *value != '\0') ? g_strdup(value) : NULL; rec->max_cmds_at_once = config_node_get_int(node, "cmdmax", 0); rec->cmd_queue_speed = config_node_get_int(node, "cmdspeed", 0); diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c index bf1d2ddf..f425b587 100644 --- a/src/irc/core/irc-servers-setup.c +++ b/src/irc/core/irc-servers-setup.c @@ -48,12 +48,18 @@ static void sig_server_setup_fill_reconn(IRC_SERVER_CONNECT_REC *conn, static void sig_server_setup_fill_connect(IRC_SERVER_CONNECT_REC *conn) { + const char *value; + if (!IS_IRC_SERVER_CONNECT(conn)) return; - conn->alternate_nick = *settings_get_str("alternate_nick") != '\0' ? - g_strdup(settings_get_str("alternate_nick")) : NULL; - conn->usermode = g_strdup(settings_get_str("usermode")); + value = settings_get_str("alternate_nick"); + conn->alternate_nick = (value != NULL && *value != '\0') ? + g_strdup(value) : NULL; + + value = settings_get_str("usermode"); + conn->usermode = (value != NULL && *value != '\0') ? + g_strdup(value) : NULL; } static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn, |