- // The tags part of the message mustn't grow longer than what is allowed by the spec. If it does,
- // remove last tag and stop adding more tags.
- //
- // One is subtracted from the limit before comparing because there must be a ' ' char after the last tag
- // which also counts towards the limit.
- if (line.size() > MAX_MESSAGE_TAG_LENGTH-1)
- {
- line.erase(prevsize);
- break;
- }
+ // The tags part of the message must not contain more client and server tags than allowed by the
+ // message tags specification. This is complicated by the tag space having separate limits for
+ // both server-originated and client-originated tags. If either of the tag limits is exceeded then
+ // the most recently added tag is removed.
+ if (i->first[0] == '+')
+ CheckTagLength(line, prevsize, client_tag_length, MAX_CLIENT_MESSAGE_TAG_LENGTH);
+ else
+ CheckTagLength(line, prevsize, server_tag_length, MAX_SERVER_MESSAGE_TAG_LENGTH);