From 5613c326c9ea1a09a7709b81f560685a67e5c67c Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 9 Jul 2016 22:55:26 +0200
Subject: 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.
---
common.c | 14 +++++++++-----
1 file 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);
}
--
cgit v1.2.3-70-g09d2