summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-07-09 22:55:26 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-07-09 22:55:26 +0200
commit5613c326c9ea1a09a7709b81f560685a67e5c67c (patch)
tree1e0c3c0950676899c433aba6ed97b5938923a628
parentdb17223df016644923fb22200326baa79b85b840 (diff)
downloadxK-5613c326c9ea1a09a7709b81f560685a67e5c67c.tar.gz
xK-5613c326c9ea1a09a7709b81f560685a67e5c67c.tar.xz
xK-5613c326c9ea1a09a7709b81f560685a67e5c67c.zip
degesch: fix CTCP handling
In `/me :\` practically no client bothers to escape the backslash but we used to interpret it as the start of an escape sequence anyway. Silly us, no one respects any standards.
-rw-r--r--common.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/common.c b/common.c
index 90fed8a..282916c 100644
--- a/common.c
+++ b/common.c
@@ -1023,6 +1023,13 @@ ctcp_intra_decode (const char *chunk, size_t len, struct str *output)
}
}
+// According to the original CTCP specification we should use
+// ctcp_intra_decode() on all parts, however no one seems to use that
+// and it breaks normal text with backslashes
+#ifndef SUPPORT_CTCP_X_QUOTES
+#define ctcp_intra_decode(s, len, output) str_append_data (output, s, len)
+#endif
+
static void
ctcp_parse_tagged (const char *chunk, size_t len, struct ctcp_chunk *output)
{
@@ -1051,9 +1058,6 @@ ctcp_parse (const char *message)
struct ctcp_chunk *result = NULL, *result_tail = NULL;
- // According to the original CTCP specification we should use
- // ctcp_intra_decode() on all parts, however no one seems to
- // use that and it breaks normal text with backslashes
size_t start = 0;
bool in_ctcp = false;
for (size_t i = 0; i < m.len; i++)
@@ -1077,7 +1081,7 @@ ctcp_parse (const char *message)
if (my_is_ctcp)
ctcp_parse_tagged (m.str + my_start, i - my_start, chunk);
else
- str_append_data (&chunk->text, m.str + my_start, i - my_start);
+ ctcp_intra_decode (m.str + my_start, i - my_start, &chunk->text);
LIST_APPEND_WITH_TAIL (result, result_tail, chunk);
}
@@ -1091,7 +1095,7 @@ ctcp_parse (const char *message)
chunk->is_partial = true;
}
else
- str_append_data (&chunk->text, m.str + start, m.len - start);
+ ctcp_intra_decode (m.str + start, m.len - start, &chunk->text);
LIST_APPEND_WITH_TAIL (result, result_tail, chunk);
}