This is an automated email from the ASF dual-hosted git repository. rjung pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new b3294ebe45 Remove redundant Json escaping of values in JsonAccessLogValve. b3294ebe45 is described below commit b3294ebe45dbe4eeda7b112e5c52c0c89e50c1c9 Author: Rainer Jung <rainer.j...@kippdata.de> AuthorDate: Thu Apr 27 10:28:07 2023 +0200 Remove redundant Json escaping of values in JsonAccessLogValve. The value escaping done in AbstractAccessLogValve is already Json compliant. --- .../apache/catalina/valves/JsonAccessLogValve.java | 43 +--------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/java/org/apache/catalina/valves/JsonAccessLogValve.java b/java/org/apache/catalina/valves/JsonAccessLogValve.java index 4c71278fe9..c7de7a47f0 100644 --- a/java/org/apache/catalina/valves/JsonAccessLogValve.java +++ b/java/org/apache/catalina/valves/JsonAccessLogValve.java @@ -17,7 +17,6 @@ package org.apache.catalina.valves; import java.io.CharArrayWriter; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -140,40 +139,6 @@ public class JsonAccessLogValve extends AccessLogValve { return new JsonWrappedElement(attributeName, true, ale); } - /** - * JSON string escaping writer - */ - private static class JsonCharArrayWriter extends CharArrayWriter { - - JsonCharArrayWriter(int i) { - super(i); - } - - @Override - public void write(int c) { - try { - super.write(JSONFilter.escape((char) c)); - } catch (IOException e) { - // ignore - } - } - - @Override - public void write(char[] c, int off, int len) { - try { - super.write(JSONFilter.escape(new String(c, off, len))); - } catch (IOException e) { - // ignore - } - } - - @Override - public void write(String str, int off, int len) { - CharSequence escaped = JSONFilter.escape(str, off, len); - super.write(escaped.toString(), 0, escaped.length()); - } - } - private static class JsonWrappedElement implements AccessLogElement, CachedElement { private CharSequence attributeName; @@ -196,13 +161,7 @@ public class JsonAccessLogValve extends AccessLogValve { if (quoteValue) { buf.append('"'); } - CharArrayWriter valueWriter = new JsonCharArrayWriter(8); - try { - delegate.addElement(valueWriter, date, request, response, time); - valueWriter.writeTo(buf); - } catch (IOException e) { - // ignore - } + delegate.addElement(buf, date, request, response, time); if (quoteValue) { buf.append('"'); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org