hirc

IRC client
Log | Files | Refs

commit 7a1eac17c35ab8f05d5279de8421fb7b71b93cd2
parent 193dbfd0cc0d2cbe16206a6d566dad0ac31526eb
Author: hhvn <dev@hhvn.uk>
Date:   Wed, 25 May 2022 19:23:07 +0100

Reimplement CTCP stripping

Diffstat:
Msrc/format.y | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/format.y b/src/format.y @@ -77,9 +77,17 @@ grammar: /* empty */ { parse_append(&parse_out[parse_pos], ""); } var: VAR LBRACE STRING RBRACE { char buf[8192]; + char *tmp; int i, num; if (strisnum($3, 0) && (num = strtoll($3, NULL, 10)) && param_len(parse_params) >= num) { - $$ = *(parse_params + num - 1); + if (num == 2 && strcmp_n(vars[var_cmd].val, "PRIVMSG") == 0 && **(parse_params + num - 1) == 1 /* ^A */) { + if (strncmp(*(parse_params + num - 1) + 1, "ACTION", CONSTLEN("ACTION")) == 0) + tmp = parse_dup(*(parse_params + num - 1) + 1 + CONSTLEN("ACTION ")); + else + tmp = parse_dup(*(parse_params + num - 1) + 1); + tmp[strlen(tmp) - 1] = '\0'; + $$ = tmp; + } else $$ = *(parse_params + num - 1); goto varfin; } if (*$3 && *($3 + strlen($3) - 1) == '-') { @@ -554,7 +562,9 @@ format(struct Window *window, char *format, struct History *hist) { break; default: if ((ret[i] & 0xC0) != 0x80) - x++; + while ((ret[i + 1] & 0xC0) == 0x80) + i++; + x++; } if (x == window->w) {