logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1483426 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java src/changes/changes.xml
Date Thu, 16 May 2013 16:00:46 GMT
Author: ggregory
Date: Thu May 16 16:00:46 2013
New Revision: 1483426

URL: http://svn.apache.org/r1483426
Log:
[LOG4J2-259] HTML layout does not specify charset in content type.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java?rev=1483426&r1=1483425&r2=1483426&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
Thu May 16 16:00:46 2013
@@ -208,7 +208,7 @@ public final class HTMLLayout extends Ab
      * @return The content type.
      */
     public String getContentType() {
-        return "text/html";
+        return "text/html; charset=" + this.getCharset();
     }
 
     private void appendThrowableAsHTML(final Throwable throwable, final StringBuilder sbuf)
{

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java?rev=1483426&r1=1483425&r2=1483426&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
Thu May 16 16:00:46 2013
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.core.Log
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.helpers.Charsets;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -31,6 +32,7 @@ import org.junit.Test;
 import java.util.List;
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 /**
  *
@@ -60,6 +62,18 @@ public class HTMLLayoutTest {
         "<td title=\"Message\">First line<br />Second line</td>";
 
 
+    @Test
+    public void testContentType() throws Exception {
+        final HTMLLayout layout = HTMLLayout.createLayout("true", null, null, null, "small",
null);
+        assertEquals("text/html; charset=UTF-8", layout.getContentType());
+    }
+    
+    @Test
+    public void testDefaultCharset() throws Exception {
+        final HTMLLayout layout = HTMLLayout.createLayout("true", null, null, null, "small",
null);
+        assertEquals(Charsets.UTF_8, layout.getCharset());
+    }
+    
     /**
      * Test case for MDC conversion pattern.
      */

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1483426&r1=1483425&r2=1483426&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Thu May 16 16:00:46 2013
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0-beta7" date="2013-??-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-259" dev="ggregory" type="fix">
+        HTML layout does not specify charset in content type.
+      </action>
       <action issue="LOG4J2-258" dev="ggregory" type="fix">
         HTML layout does not output meta element for charset.
       </action>



Mime
View raw message