diff options
-rw-r--r-- | degesch.c | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -4487,6 +4487,25 @@ irc_handle_isupport_prefix (struct server *s, char *value) } static void +unescape_isupport_value (const char *value, struct str *output) +{ + const char *alphabet = "0123456789abcdef", *a, *b; + for (const char *p = value; *p; p++) + { + if (p[0] == '\\' + && p[1] == 'x' + && p[2] && (a = strchr (alphabet, tolower_ascii (p[2]))) + && p[3] && (b = strchr (alphabet, tolower_ascii (p[3])))) + { + str_append_c (output, (a - alphabet) << 4 | (b - alphabet)); + p += 3; + } + else + str_append_c (output, *p); + } +} + +static void irc_handle_rpl_isupport (struct server *s, const struct irc_message *msg) { if (msg->params.len < 2) @@ -4499,8 +4518,14 @@ irc_handle_rpl_isupport (struct server *s, const struct irc_message *msg) char *value = param + strcspn (param, "="); if (*value) *value++ = '\0'; + struct str value_unescaped; + str_init (&value_unescaped); + unescape_isupport_value (value, &value_unescaped); + if (!strcmp (param, "PREFIX")) - irc_handle_isupport_prefix (s, value); + irc_handle_isupport_prefix (s, value_unescaped.str); + + str_free (&value_unescaped); } // TODO: initialize key_strxfrm according to server properties; |