MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / LogEscapeMessage

Function LogEscapeMessage

src/logging.cpp:280–291  ·  view source on GitHub ↗

Belts and suspenders: make sure outgoing log messages don't contain * potentially suspicious characters, such as terminal control codes. * * This escapes control characters except newline ('\n') in C syntax. * It escapes instead of removes them to still allow for troubleshooting * issues where they accidentally end up in strings. */

Source from the content-addressed store, hash-verified

278 * issues where they accidentally end up in strings.
279 */
280 std::string LogEscapeMessage(const std::string& str) {
281 std::string ret;
282 for (char ch_in : str) {
283 uint8_t ch = (uint8_t)ch_in;
284 if ((ch >= 32 || ch == '\n') && ch != '\x7f') {
285 ret += ch_in;
286 } else {
287 ret += strprintf("\\x%02x", ch);
288 }
289 }
290 return ret;
291 }
292
293}
294

Callers 1

LogPrintStrMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected