msgbuf: do a better job of handling gotchas with parsing tags

This commit is contained in:
William Pitcock 2016-02-10 21:16:28 -06:00
parent c84003aeb5
commit 08006c16f8

View file

@ -43,7 +43,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
if (*ch == '@') if (*ch == '@')
{ {
char *t = ch++; char *t = ch + 1;
ch = strchr(ch, ' '); ch = strchr(ch, ' ');
if (ch != NULL) if (ch != NULL)
@ -54,21 +54,28 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
char *eq = strchr(t, '='); char *eq = strchr(t, '=');
if (next != NULL) if (next != NULL)
{
*next = '\0'; *next = '\0';
if (eq > next) if (eq > next)
eq = NULL; eq = NULL;
}
if (eq != NULL) if (eq != NULL)
*eq = '\0'; *eq++ = '\0';
msgbuf_append_tag(msgbuf, t, eq); if (*t && *t != ' ')
msgbuf_append_tag(msgbuf, t, eq);
else
break;
if (next != NULL) if (next != NULL)
t = next + 1; t = next + 1;
else else
break; break;
} }
*ch++ = '\0';
} }
} }