diff options
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/channel-events.c | 8 | ||||
-rw-r--r-- | src/irc/core/irc-nicklist.c | 19 | ||||
-rw-r--r-- | src/irc/core/irc-servers-setup.c | 11 | ||||
-rw-r--r-- | src/irc/core/irc.c | 34 | ||||
-rw-r--r-- | src/irc/core/sasl.c | 6 |
5 files changed, 67 insertions, 11 deletions
diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index b0bddab2..46bbd5fa 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -138,7 +138,13 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, g_free_not_null(chanrec->topic_by); chanrec->topic_by = g_strdup(setby); - chanrec->topic_time = settime; + if (chanrec->topic_by == NULL) { + /* ensure invariant topic_time > 0 <=> topic_by != NULL. + this could be triggered by a topic command without sender */ + chanrec->topic_time = 0; + } else { + chanrec->topic_time = settime; + } signal_emit("channel topic changed", 1, chanrec); } diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c index 1cb1f3e9..3e16db80 100644 --- a/src/irc/core/irc-nicklist.c +++ b/src/irc/core/irc-nicklist.c @@ -323,8 +323,9 @@ static void event_nick_invalid(IRC_SERVER_REC *server, const char *data) static void event_nick_in_use(IRC_SERVER_REC *server, const char *data) { - char *str, *cmd; + char *str, *cmd, *params, *nick; int n; + gboolean try_alternate_nick; g_return_if_fail(data != NULL); @@ -332,11 +333,21 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data) /* Already connected, no need to handle this anymore. */ return; } + + try_alternate_nick = g_ascii_strcasecmp(server->nick, server->connrec->nick) == 0 && + server->connrec->alternate_nick != NULL && + g_ascii_strcasecmp(server->connrec->alternate_nick, server->nick) != 0; + + params = event_get_params(data, 2, NULL, &nick); + if (g_ascii_strcasecmp(server->nick, nick) != 0) { + /* the server uses a nick different from the one we send */ + g_free(server->nick); + server->nick = g_strdup(nick); + } + g_free(params); /* nick already in use - need to change it .. */ - if (g_ascii_strcasecmp(server->nick, server->connrec->nick) == 0 && - server->connrec->alternate_nick != NULL && - g_ascii_strcasecmp(server->connrec->alternate_nick, server->nick) != 0) { + if (try_alternate_nick) { /* first try, so try the alternative nick.. */ g_free(server->nick); server->nick = g_strdup(server->connrec->alternate_nick); diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c index bae7d3b4..e79557ab 100644 --- a/src/irc/core/irc-servers-setup.c +++ b/src/irc/core/irc-servers-setup.c @@ -116,14 +116,17 @@ static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn, static void init_userinfo(void) { + unsigned int changed; const char *set, *nick, *user_name, *str; + changed = 0; /* check if nick/username/realname wasn't read from setup.. */ set = settings_get_str("real_name"); if (set == NULL || *set == '\0') { str = g_getenv("IRCNAME"); settings_set_str("real_name", str != NULL ? str : g_get_real_name()); + changed |= USER_SETTINGS_REAL_NAME; } /* username */ @@ -134,6 +137,7 @@ static void init_userinfo(void) str != NULL ? str : g_get_user_name()); user_name = settings_get_str("user_name"); + changed |= USER_SETTINGS_USER_NAME; } /* nick */ @@ -143,15 +147,20 @@ static void init_userinfo(void) settings_set_str("nick", str != NULL ? str : user_name); nick = settings_get_str("nick"); + changed |= USER_SETTINGS_NICK; } /* host name */ set = settings_get_str("hostname"); if (set == NULL || *set == '\0') { str = g_getenv("IRCHOST"); - if (str != NULL) + if (str != NULL) { settings_set_str("hostname", str); + changed |= USER_SETTINGS_HOSTNAME; + } } + + signal_emit("irssi init userinfo changed", 1, GUINT_TO_POINTER(changed)); } static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node) diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c index 4dce3fcf..a740b0da 100644 --- a/src/irc/core/irc.c +++ b/src/irc/core/irc.c @@ -40,6 +40,8 @@ static int signal_server_incoming; # define MAX_SOCKET_READS 5 #endif +static void strip_params_colon(char *const); + /* The core of the irc_send_cmd* functions. If `raw' is TRUE, the `cmd' won't be checked at all if it's 512 bytes or not, or if it contains line feeds or not. Use with extreme caution! */ @@ -269,8 +271,9 @@ char *event_get_params(const char *data, int count, ...) while (count-- > 0) { str = (char **) va_arg(args, char **); if (count == 0 && rest) { - /* put the rest to last parameter */ - tmp = *datad == ':' ? datad+1 : datad; + /* Put the rest into the last parameter. */ + strip_params_colon(datad); + tmp = datad; } else { tmp = event_get_param(&datad); } @@ -281,6 +284,33 @@ char *event_get_params(const char *data, int count, ...) return duprec; } +/* Given a string containing <params>, strip any colon prefixing <trailing>. */ +static void strip_params_colon(char *const params) +{ + char *s; + + if (params == NULL) { + return; + } + + s = params; + while (*s != '\0') { + if (*s == ':') { + memmove(s, s+1, strlen(s+1)+1); + return; + } + + s = strchr(s, ' '); + if (s == NULL) { + return; + } + + while (*s == ' ') { + s++; + } + } +} + static void irc_server_event(IRC_SERVER_REC *server, const char *line, const char *nick, const char *address) { diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c index 635b7dfb..2b589579 100644 --- a/src/irc/core/sasl.c +++ b/src/irc/core/sasl.c @@ -30,16 +30,16 @@ * Based on IRCv3 SASL Extension Specification: * http://ircv3.net/specs/extensions/sasl-3.1.html */ -#define AUTHENTICATE_CHUNK_SIZE 400 // bytes +#define AUTHENTICATE_CHUNK_SIZE 400 /* bytes */ /* * Maximum size to allow the buffer to grow to before the next fragment comes in. Note that * due to the way fragmentation works, the maximum message size will actually be: * floor(AUTHENTICATE_MAX_SIZE / AUTHENTICATE_CHUNK_SIZE) + AUTHENTICATE_CHUNK_SIZE - 1 */ -#define AUTHENTICATE_MAX_SIZE 8192 // bytes +#define AUTHENTICATE_MAX_SIZE 8192 /* bytes */ -#define SASL_TIMEOUT (20 * 1000) // ms +#define SASL_TIMEOUT (20 * 1000) /* ms */ static gboolean sasl_timeout(IRC_SERVER_REC *server) { |