Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
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.
|
ACK 40bb43f |
|
tACK 40bb43f |
|
tACK 40bb43f Tested on Linux x86_64 (Ubuntu 24.04), g++ 13.3.0, Release: Nit: the two new checks don't independently pin down both boundaries. Changing the lower bound to Adding after line 141: BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage("\xc2\x7f"), "\xc2" R"(\x7f)");
BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage(std::string_view{"\xc2\x9b", 1}), "\xc2");Both pass on this branch. Each fails only with its corresponding mutant (lines 142 and 143, respectively; Debian 13 x86_64, GCC 14.2.0, Release). Nit: the |
|
@cyb3ralbert thanks, both nits are right: the two extra checks pin each boundary, and the comments should mention the C1 exception. I will apply them in a push if a maintainer prefers, and otherwise leave the head as it is, so the three reviews of 40bb43f stay valid. |

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 ]andESC Pforms.I escape the two-byte sequences 0xC2 0x80 to 0xC2 0x9F as
\xc2\x9band 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 intest_LogEscapeMessagefail on master and pass with the change.