From 4d2f203026c44bd87e0b599aacce062395516730 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 20 Feb 2016 18:41:16 -0600 Subject: [PATCH] msgbuf: msgbuf_unparse_tags(): don't send a tags sigil unless tags will actually be emitted --- ircd/msgbuf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ircd/msgbuf.c b/ircd/msgbuf.c index 0e33fd6fd..3aae2157d 100644 --- a/ircd/msgbuf.c +++ b/ircd/msgbuf.c @@ -114,11 +114,28 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line) return 0; } +static int +msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask) +{ + int i; + + for (i = 0; i < msgbuf->n_tags; i++) + { + if ((msgbuf->tags[i].capmask & capmask) != 0) + return 1; + } + + return 0; +} + static void msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) { int i; + if (!msgbuf_has_matching_tags(msgbuf, capmask)) + return; + *buf = '@'; for (i = 0; i < msgbuf->n_tags; i++)