summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-12-11 23:48:23 +0100
committerGitHub <noreply@github.com>2017-12-11 23:48:23 +0100
commit48e909dde758efe19d4cd707b742370a042d0559 (patch)
tree92dc91159be89cfbaa16b930d6111056ca986b29 /src/irc
parentba6681de84f1a237484eb42691ac64897c3b380e (diff)
parentb0637ad6ea8784d3b2be829ca40f9dddf0c049fc (diff)
downloadirssi-48e909dde758efe19d4cd707b742370a042d0559.zip
Merge pull request #766 from horgh/horgh/mode-parsing
Fix MODE parameter parsing
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/core/irc.c34
1 files changed, 32 insertions, 2 deletions
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)
{