aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/string.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-03-04 09:38:13 +0100
committerGitHub Enterprise <[email protected]>2025-03-04 09:38:13 +0100
commit2232eb28256ec54beaf3dbe06f5176698c7245a0 (patch)
treede7ae8468a0b4b79003b0c0f1fcbab72abdc36d6 /src/zencore/string.cpp
parentrefactor use chunk sequence download (#291) (diff)
downloadzen-2232eb28256ec54beaf3dbe06f5176698c7245a0.tar.xz
zen-2232eb28256ec54beaf3dbe06f5176698c7245a0.zip
limit and validate responses before logging the text (#292)
Improvement: When logging HTTP responses, the body is now sanity checked to ensure it is human readable, and the length of the output is capped to prevent inadvertent log bloat
Diffstat (limited to 'src/zencore/string.cpp')
-rw-r--r--src/zencore/string.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/zencore/string.cpp b/src/zencore/string.cpp
index 242d41abe..a0d8c927f 100644
--- a/src/zencore/string.cpp
+++ b/src/zencore/string.cpp
@@ -99,6 +99,20 @@ FilepathFindExtension(const std::string_view& Path, const char* ExtensionToMatch
//////////////////////////////////////////////////////////////////////////
+bool
+IsValidUtf8(const std::string_view& str)
+{
+ return utf8::is_valid(begin(str), end(str));
+}
+
+std::string_view::const_iterator
+FindFirstInvalidUtf8Byte(const std::string_view& str)
+{
+ return utf8::find_invalid(begin(str), end(str));
+}
+
+//////////////////////////////////////////////////////////////////////////
+
void
Utf8ToWide(const char8_t* Str8, WideStringBuilderBase& OutString)
{