mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 17:23:15 +02:00
irc: fix parsing of messages with trailing spaces and no trailing parameter (closes #1803)
This commit is contained in:
@@ -31,6 +31,7 @@ Bug fixes::
|
||||
|
||||
* irc: fix duplicated channels in autojoin option when autojoin_dynamic is enabled (issue #1795)
|
||||
* irc: fix display of TOPIC and QUIT messages with an empty trailing parameter (issue #1797)
|
||||
* irc: fix parsing of messages with trailing spaces and no trailing parameter (issue #1803)
|
||||
* guile: fix function hdata_get_string
|
||||
* javascript: fix return of long value in functions infolist_time, hdata_long and hdata_time
|
||||
* php: fix function hdata_compare
|
||||
|
||||
@@ -59,7 +59,7 @@ void
|
||||
irc_message_parse_params (const char *parameters,
|
||||
char ***params, int *num_params)
|
||||
{
|
||||
const char *ptr_params, *pos_end, *pos_next;
|
||||
const char *ptr_params, *pos_end;
|
||||
char **new_params;
|
||||
int alloc_params, trailing;
|
||||
|
||||
@@ -104,13 +104,6 @@ irc_message_parse_params (const char *parameters,
|
||||
}
|
||||
if (!pos_end)
|
||||
pos_end = ptr_params + strlen (ptr_params);
|
||||
pos_next = pos_end;
|
||||
while (pos_next[0] == ' ')
|
||||
{
|
||||
pos_next++;
|
||||
}
|
||||
if (!pos_next[0])
|
||||
pos_end = pos_next;
|
||||
if (params)
|
||||
{
|
||||
alloc_params++;
|
||||
|
||||
@@ -355,6 +355,16 @@ TEST(IrcMessage, ParseParams)
|
||||
POINTERS_EQUAL(NULL, params[1]);
|
||||
string_free_split (params);
|
||||
|
||||
/* single parameter with trailing space */
|
||||
params = NULL;
|
||||
num_params = -1;
|
||||
irc_message_parse_params ("param1 ", ¶ms, &num_params);
|
||||
LONGS_EQUAL(1, num_params);
|
||||
CHECK(params);
|
||||
STRCMP_EQUAL("param1", params[0]);
|
||||
POINTERS_EQUAL(NULL, params[1]);
|
||||
string_free_split (params);
|
||||
|
||||
/* two parameters */
|
||||
params = NULL;
|
||||
num_params = -1;
|
||||
@@ -373,7 +383,7 @@ TEST(IrcMessage, ParseParams)
|
||||
LONGS_EQUAL(2, num_params);
|
||||
CHECK(params);
|
||||
STRCMP_EQUAL("param1", params[0]);
|
||||
STRCMP_EQUAL("param2 ", params[1]);
|
||||
STRCMP_EQUAL("param2", params[1]);
|
||||
POINTERS_EQUAL(NULL, params[2]);
|
||||
string_free_split (params);
|
||||
|
||||
@@ -384,7 +394,7 @@ TEST(IrcMessage, ParseParams)
|
||||
LONGS_EQUAL(2, num_params);
|
||||
CHECK(params);
|
||||
STRCMP_EQUAL("param1", params[0]);
|
||||
STRCMP_EQUAL("param2 ", params[1]);
|
||||
STRCMP_EQUAL("param2", params[1]);
|
||||
POINTERS_EQUAL(NULL, params[2]);
|
||||
string_free_split (params);
|
||||
|
||||
|
||||
@@ -2003,7 +2003,7 @@ TEST(IrcProtocolWithServer, wallops)
|
||||
CHECK_ERROR_PARAMS("wallops", 0, 1);
|
||||
|
||||
RECV(":alice!user@host WALLOPS message ");
|
||||
CHECK_SRV("-- Wallops from alice (user@host): message ");
|
||||
CHECK_SRV("-- Wallops from alice (user@host): message");
|
||||
|
||||
RECV(":alice!user@host WALLOPS :message from admin ");
|
||||
CHECK_SRV("-- Wallops from alice (user@host): message from admin ");
|
||||
|
||||
Reference in New Issue
Block a user