diff options
author | ShadowNinja <ShadowNinja@users.noreply.github.com> | 2022-01-01 16:44:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-01 22:44:56 +0100 |
commit | 29d2b2ccd06cdd831a7fac66928bfa612003945c (patch) | |
tree | 408d8930084bab87a26af73aa4548399756cebf2 /src/util/string.cpp | |
parent | 544b9d5c72f690d6a729053616d26e023f7e0e28 (diff) | |
download | dragonfireclient-29d2b2ccd06cdd831a7fac66928bfa612003945c.tar.xz |
Print announce error response (#11878)
Fix HTTPFetch caller and request ID to 64 bits
Check that allocated caller ID is not DISCARD
Print body if serverlist request returns error
Don't print control characters from HTTP responses
Document special HTTPFetch caller IDs
Allow unicode to be printed
Diffstat (limited to 'src/util/string.cpp')
-rw-r--r-- | src/util/string.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp index 8be5e320a..bc4664997 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -887,3 +887,19 @@ std::string sanitizeDirName(const std::string &str, const std::string &optional_ return wide_to_utf8(safe_name); } + + +void safe_print_string(std::ostream &os, const std::string &str) +{ + std::ostream::fmtflags flags = os.flags(); + os << std::hex; + for (const char c : str) { + if (IS_ASCII_PRINTABLE_CHAR(c) || IS_UTF8_MULTB_START(c) || + IS_UTF8_MULTB_INNER(c) || c == '\n' || c == '\t') { + os << c; + } else { + os << '<' << std::setw(2) << (int)c << '>'; + } + } + os.setf(flags); +} |