You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/06/08 12:19:24 UTC

[GitHub] [trafficserver] hnakamur commented on a diff in pull request #8886: Add escape json for logging

hnakamur commented on code in PR #8886:
URL: https://github.com/apache/trafficserver/pull/8886#discussion_r892287146


##########
proxy/logging/LogAccess.cc:
##########
@@ -643,6 +643,126 @@ LogAccess::unmarshal_str(char **buf, char *dest, int len, LogSlice *slice)
   return -1;
 }
 
+static int
+escape_json(char *dest, const char *buf, int len)
+{
+  ink_assert(buf != nullptr);
+
+  int escaped_len = 0;
+
+  for (int i = 0; i < len; i++) {
+    char c = buf[i];
+    switch (c) {

Review Comment:
   Thanks for your suggestion.
   I tried to modify `escape_json` using bitset but I found that I need the mapping like `\b` to `b`.
   
   I made a modified version at
   https://github.com/hnakamur/json-escape-cpp-experiment/blob/main/test.cpp
   
   This version properly escapes the DEL `0x7f` character too.
   
   Can I replace `escape_json` with this one?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org