• src/sbbs3/getmsg.cpp sbbs.h

    From Rob Swindell (on Windows 11)@VERT to Git commit to main/sbbs/master on Sat Oct 31 23:16:24 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/804e26960745a6d1d29be32f
    Modified Files:
    src/sbbs3/getmsg.cpp sbbs.h
    Log Message:
    Fix CP437 header templates printed as UTF-8 for UTF-8-flagged messages

    msghdr_text() converts a CP437 text.dat template (MsgSubj, MsgTo,
    MsgFrom, the message list formats) to UTF-8 into a 128-byte buffer
    when a message's header fields are flagged UTF-8. The stock MsgSubj
    string is 72 CP437 bytes with 30 box-drawing characters: exactly 128
    bytes as UTF-8. Since 99b0b63767 (2019-08-03) that conversion only
    succeeded by writing the NUL-terminator one byte past the buffer.

    bb5ff19c18 (2026-07-29) made cp437_to_utf8_str() reserve the
    terminator inside the passed size, so the MsgSubj conversion now fails
    and msghdr_text() falls back to the raw CP437 template, which the
    caller still prints in P_UTF8 mode, i.e. untranslated. On a UTF-8
    terminal the first header line of every message with the HFIELDS_UTF8
    aux attribute (e.g. all posts from a system that flags web-posted
    headers as UTF-8) came out as CP437 mojibake. Messages without the
    flag never take this path and were unaffected.

    Size the buffer for any text.dat item (MAX_TEXTDAT_ITEM_LEN CP437
    characters of at most three UTF-8 bytes each). And since text.ini and bbs.replace_text() can install longer strings, make the failure path
    coherent: msghdr_text() logs a warning and returns NULL when the
    template can't be converted, and show_msghdr() (via the new
    show_msghdr_line()) and list_msg() then display that line entirely in
    CP437, header fields included, instead of mixing charsets. A template
    with nothing to convert is returned as-is rather than being treated as
    a failure.

    Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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