Bug 58035 - XMLLayout writes illegal characters to XML file
Summary: XMLLayout writes illegal characters to XML file
Status: NEW
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on: 49354
Blocks:
  Show dependency tree
 
Reported: 2015-06-14 21:47 UTC by Pablo
Modified: 2015-06-14 23:25 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pablo 2015-06-14 21:47:35 UTC
+++ This bug was initially created as a clone of Bug #49354 +++

XMLLayout does not appear to escape or scrub the log message to deal with illegal characters. This can result in invalid XML output by log4j, which in turn can cause XML parsers downstream to blow up.

A corner case we encountered while using log4j v1.2.15 produced the attached XML output. The message, which usually has normal text, ended up having some illegal XML characters in it. Stylus Studio reports the error on line 2, column 119 as follows:
  FATAL ERROR: Invalid character (Unicode: 0x15)

This character is indeed illegal in XML, as per:
http://www.xml.com/axml/target.html#sec-cdata-sect

A nice summary can be found here:
http://www.coderanch.com/t/124970/XML/Invalid-Character-inside-CDATA

XMLLayout should ensure that what it write is legal XML, either by escaping illegal characters, removing them, or replacing them.
Comment 1 Gary Gregory 2015-06-14 23:25:57 UTC
What happens with 1.2.17? Otherwise try 2.x with the 1.2 compatibility jar. 1.2 is not maintained atm.