• src/sbbs3/ansi_parser.cpp ansi_parser.h ansi_parser_test.cpp

    From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Thursday, September 24, 2026 21:22:49
    https://gitlab.synchro.net/main/sbbs/-/commit/2cbb0c02efb8a0cc02e14d6e
    Modified Files:
    src/sbbs3/ansi_parser.cpp ansi_parser.h ansi_parser_test.cpp
    Log Message:
    ANSI_Parser: cap CSI parameters and intermediate bytes

    ansi_sequence was already limited to max_sequence_len (1024) bytes, but ansi_params and ansi_ibs grew without limit. The terminal output path
    parses every byte sent to the user, and handle_SGR_sequence() calls
    get_pval() once per parameter, each call copying and rescanning the whole parameter string: cubic in the sequence length. A single 40 KB SGR
    sequence in a message took about 53 seconds of CPU to display, per reader.

    Parameter and intermediate bytes past the cap are now dropped and the
    sequence completes normally. It isn't treated as broken, because putmsg() prints the rest of a broken sequence as text. The filters putmsg() applies
    look only at the final byte, the first parameter byte, exact intermediate strings and the start of ansi_sequence, so truncation doesn't change what
    it strips.

    Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net