• Mail Server: a UTF-8 character split across two encoded words leaves t

    From Rob Swindell@VERT to GitLab issue in main/sbbs on Mon Nov 23 21:48:37 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1416
    2026-11-23 21:48:37 -0800

    When a UTF-8 character is split across two adjacent RFC 2047 encoded words in a received header, the Mail Server stores the correct bytes but does not flag the message as UTF-8 (`MSG_HFIELDS_UTF8`), so the whole field is then shown as CP437 (mojibake).

    Code references are as of master 093321f948 (hero-4-babies, 2026-11-23).

    ## Example

    ```
    Subject: =?UTF-8?Q?caf=C3?= =?UTF-8?Q?=A9?=
    ```

    decodes to the bytes of "cafe" with an e-acute (`caf` 0xC3 0xA9), which is valid UTF-8, but the flag is not set.

    ## Cause

    `mimehdr_value_decode()` (`src/sbbs3/mailsrvr.cpp:2723`) checks `utf8_str_is_valid()` on each encoded word separately (lines 2754 and 2762). Neither `caf` + 0xC3 nor 0xA9 is valid UTF-8 on its own.

    RFC 2047 (section 5) says each encoded word must contain whole characters, so the sender is at fault, but some mailers do split them, and the joined result is valid.

    ## Suggested fix

    Decide on UTF-8 once, from the whole decoded field value (all of its encoded words joined), instead of per encoded word.

    `exec/load/mimehdr.js` has the same problem: `to_cp437()` converts each encoded word from UTF-8 separately.

    -- *Authored by Claude (Claude Code), on behalf of @rswindell*

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