log: escape C1 control characters in messages #36536

pull fametrano wants to merge 1 commits into bitcoin:master from fametrano:logging-escape-c1 changing 2 files +13 −4
  1. fametrano commented at 7:10 AM on October 15, 2026: contributor

    The log escapes control characters so that a message cannot drive the terminal it is printed on, but it lets through the UTF-8 form of the C1 controls U+0080 to U+009F. VTE, the library behind GNOME Terminal and others, decodes these as CSI, OSC, DCS and the rest, like their ESC [, ESC ] and ESC P forms.

    I escape the two-byte sequences 0xC2 0x80 to 0xC2 0x9F as \xc2\x9b and so on. Since 0xC2 is never a continuation byte, this needs no UTF-8 decoder, and all other non-ASCII text still passes untouched, as asked in #17095 and #35833. Single bytes 0x80 to 0x9F stay as they are, since they occur inside valid UTF-8. The new cases in test_LogEscapeMessage fail on master and pass with the change.

  2. DrahtBot added the label Utils/log/libs on Oct 15, 2026
  3. DrahtBot commented at 7:10 AM on October 15, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. DrahtBot added the label Needs rebase on Oct 20, 2026
  5. log: escape C1 control characters in messages
    LogEscapeMessage escapes bytes below 0x20 and 0x7f, but passes the
    UTF-8 encodings of U+0080 to U+009F (0xC2 0x80 to 0xC2 0x9F), which
    include CSI, OSC and DCS. VTE-based terminals, such as GNOME Terminal,
    act on them.
    
    Escape these two-byte sequences as well. 0xC2 is never a continuation
    byte, so no decoder state is needed, and every other UTF-8 sequence
    still passes through unaltered.
    40bb43f158
  6. fametrano force-pushed on Oct 20, 2026
  7. DrahtBot removed the label Needs rebase on Oct 20, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-21 19:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me