You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ramanathan1504 (via GitHub)" <gi...@apache.org> on 2026/10/20 18:49:48 UTC

Re: [PR] Render HTML formatted pattern messages [logging-log4j2]

ramanathan1504 commented on code in PR #4371:
URL: https://github.com/apache/logging-log4j2/pull/4371#discussion_r4328910967


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/HtmlTextRenderer.java:
##########
@@ -16,22 +16,26 @@
  */
 package org.apache.logging.log4j.core.pattern;
 
+import org.apache.logging.log4j.util.StringBuilders;
+
 /**
- * TODO Renders an input as HTML output.
+ * Renders input text as HTML-escaped text.
  */
 public final class HtmlTextRenderer implements TextRenderer {
 
-    public HtmlTextRenderer(final String[] formats) {
-        // TODO Auto-generated constructor stub
-    }
+    public HtmlTextRenderer(final String[] formats) {}
 
     @Override
     public void render(final String input, final StringBuilder output, final String styleName) {

Review Comment:
   This overload is not reached from `MessagePatternConverter`, so no test covers it. Can we add a direct test? Something like:
   
   ```java
   @Test
   void testHtmlTextRendererEscapesString() {
       final StringBuilder sb = new StringBuilder("prefix:");
       new HtmlTextRenderer(null).render("<b> & '", sb, null);
       assertEquals("prefix:&lt;b&gt; &amp; &apos;", sb.toString());
   }
   ```



-- 
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: notifications-unsubscribe@logging.apache.org

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