mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-25 06:50:17 +00:00
Tighten IRCv3 STS spec handling
This commit is contained in:
@@ -1796,6 +1796,36 @@ inbound_cap_ack (server *serv, char *nick, char *extensions,
|
||||
inbound_toggle_caps (serv, extensions, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
inbound_cap_new (server *serv, char *nick, char *extensions,
|
||||
const message_tags_data *tags_data)
|
||||
{
|
||||
if (extensions)
|
||||
{
|
||||
char **tokens = g_strsplit (extensions, " ", 0);
|
||||
int i;
|
||||
|
||||
for (i = 0; tokens[i]; i++)
|
||||
{
|
||||
char **parts = g_strsplit (tokens[i], "=", 2);
|
||||
|
||||
if (!g_strcmp0 (parts[0], "sts") && parts[1] && parts[1][0])
|
||||
{
|
||||
sts_handle_capability (serv, parts[1]);
|
||||
}
|
||||
|
||||
g_strfreev (parts);
|
||||
}
|
||||
|
||||
g_strfreev (tokens);
|
||||
}
|
||||
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CAPACK, serv->server_session, nick, extensions,
|
||||
NULL, NULL, 0, tags_data->timestamp);
|
||||
|
||||
inbound_toggle_caps (serv, extensions, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
inbound_cap_del (server *serv, char *nick, char *extensions,
|
||||
const message_tags_data *tags_data)
|
||||
|
||||
@@ -95,6 +95,8 @@ void inbound_cap_ls (server *serv, char *nick, char *extensions,
|
||||
void inbound_cap_nak (server *serv, char *extensions, const message_tags_data *tags_data);
|
||||
void inbound_cap_list (server *serv, char *nick, char *extensions,
|
||||
const message_tags_data *tags_data);
|
||||
void inbound_cap_new (server *serv, char *nick, char *extensions,
|
||||
const message_tags_data *tags_data);
|
||||
void inbound_cap_del (server *serv, char *nick, char *extensions,
|
||||
const message_tags_data *tags_data);
|
||||
void inbound_sasl_authenticate (server *serv, char *data);
|
||||
|
||||
@@ -1359,12 +1359,18 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||
tags_data);
|
||||
}
|
||||
else if (g_ascii_strncasecmp(word[4], "LS", 2) == 0 || g_ascii_strncasecmp(word[4], "NEW", 3) == 0)
|
||||
else if (g_ascii_strncasecmp(word[4], "LS", 2) == 0)
|
||||
{
|
||||
inbound_cap_ls (serv, word[1],
|
||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||
tags_data);
|
||||
}
|
||||
else if (g_ascii_strncasecmp(word[4], "NEW", 3) == 0)
|
||||
{
|
||||
inbound_cap_new (serv, word[1],
|
||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||
tags_data);
|
||||
}
|
||||
else if (g_ascii_strncasecmp(word[4], "NAK", 3) == 0)
|
||||
{
|
||||
inbound_cap_nak (serv, word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data);
|
||||
|
||||
@@ -305,6 +305,7 @@ sts_parse_value (const char *value, guint16 *port, guint64 *duration, gboolean *
|
||||
{
|
||||
char **tokens;
|
||||
gsize i;
|
||||
char *end;
|
||||
|
||||
if (!value || !*value)
|
||||
{
|
||||
@@ -349,8 +350,9 @@ sts_parse_value (const char *value, guint16 *port, guint64 *duration, gboolean *
|
||||
continue;
|
||||
}
|
||||
|
||||
port_value = g_ascii_strtoll (val, NULL, 10);
|
||||
if (port_value > 0 && port_value <= G_MAXUINT16)
|
||||
end = NULL;
|
||||
port_value = g_ascii_strtoll (val, &end, 10);
|
||||
if (end && *end == '\0' && port_value > 0 && port_value <= G_MAXUINT16)
|
||||
{
|
||||
*port = (guint16) port_value;
|
||||
*has_port = TRUE;
|
||||
@@ -371,7 +373,12 @@ sts_parse_value (const char *value, guint16 *port, guint64 *duration, gboolean *
|
||||
continue;
|
||||
}
|
||||
|
||||
duration_value = g_ascii_strtoull (val, NULL, 10);
|
||||
end = NULL;
|
||||
duration_value = g_ascii_strtoull (val, &end, 10);
|
||||
if (!end || *end != '\0')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
*duration = duration_value;
|
||||
*has_duration = TRUE;
|
||||
}
|
||||
@@ -612,7 +619,7 @@ sts_handle_capability (struct server *serv, const char *value)
|
||||
{
|
||||
time_t now = time (NULL);
|
||||
time_t expires_at = now + (time_t) duration;
|
||||
guint16 effective_port = 0;
|
||||
guint16 effective_port = (guint16) serv->port;
|
||||
sts_profile *existing_profile;
|
||||
sts_profile *profile;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user