Fix +S stripping too much on incorrect color codes.

Reported by semioriginal in https://bugs.unrealircd.org/view.php?id=5908
with the patch also by semioriginal.
This commit is contained in:
Bram Matthys 2023-03-18 13:58:59 +01:00
parent 5cdcb95cdf
commit 3bccc63125
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98
2 changed files with 7 additions and 2 deletions
src

View file

@ -2595,7 +2595,8 @@ const char *StripControlCodesEx(const char *text, char *output, size_t outputlen
while (len > 0)
{
if ( col && ((isdigit(*text) && nc < 2) || (*text == ',' && nc < 3)))
if ((col && isdigit(*text) && nc < 2) ||
((col == 1) && (*text == ',') && isdigit(text[1]) && (nc > 0) && (nc < 3)))
{
nc++;
if (*text == ',')

View file

@ -537,11 +537,15 @@ const char *_StripColors(const char *text)
while (len > 0)
{
if ((col && isdigit(*text) && nc < 2) || (col && *text == ',' && nc < 3))
if ((col && isdigit(*text) && nc < 2) ||
((col == 1) && (*text == ',') && isdigit(text[1]) && (nc > 0) && (nc < 3)))
{
nc++;
if (*text == ',')
{
nc = 0;
col++;
}
}
/* Syntax for RGB is ^DHHHHHH where H is a hex digit.
* If < 6 hex digits are specified, the code is displayed