Bug 37560 - Does not handle embedded xml correctly
Does not handle embedded xml correctly
Status: RESOLVED FIXED
Product: Log4j
Classification: Unclassified
Component: Layout
unspecified
Other other
: P2 normal
: ---
Assigned To: log4j-dev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-11-18 20:58 UTC by Richard Hansen
Modified: 2007-08-22 16:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Hansen 2005-11-18 20:58:28 UTC
Chainsaw would not parse a file that had xml embedded in an NDC. Here are the
error messages :

Parsing error on line 345 and column 418
The element type "log4j:NDC" must be terminated by the matching end-tag
</log4j:NDC>".

Here is the event:

<log4j:event logger="com.tlr.bis.online.charges.jaxprc.trmr.StandardTRMRHandler"
timestamp="1132342098624" level="DEBUG" thread="WebContainer : 0">
<log4j:message><![CDATA[handleFault]]></log4j:message>
<log4j:NDC><![CDATA[<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><soapenv:Fault><faultcode>Client</faultcode><faultstring><![CDATA[The
value "12-31-2005" has an invalid format for
EffectiveDate]]></faultstring><faultactor/><detail
encodingStyle=""><olc:DataFormatException
xmlns:olc="http://thomson.com/tlr/bis/online/charges/"><severity>error</severity><dateTime>2005-11-18T13:28:18.173</dateTime><transactionId></transactionId><EffectiveDate>12-31-2005</EffectiveDate></olc:DataFormatException></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>]]></log4j:NDC>
</log4j:event>
Comment 1 Curt Arnold 2006-08-31 21:03:53 UTC
Not Chainsaw's fault.  The serializer (I assume that log4j's XMLLayout) used to write the sample document 
is naive and just dropped the NDC content into a CDATA section.  Unfortunately, the termination of the 
CDATA section within the NDC content (the ]]>) prematurely ended the CDATA section added by the 
serialization.  You can't nest CDATA sections.

Solutions would be to use a real XML serializer (like that provided by Xerces) or to make the log4j 
serializer smarter and not depend on CDATA sections (that is, it would convert <, > and & to &lt;, &gt; and 
&amp; and likely convert characters with code points greater than 127 to &#NNN; 
Comment 2 Curt Arnold 2007-08-22 16:24:26 UTC
I believe that XMLLayout has been modified to detect embedded CDATA sections.  If not, you can use 
XSLTLayout in the extras companion.  Marking as fixed.  Reopen if you still see the problem in 1.2.15.
Comment 3 Curt Arnold 2007-08-22 16:56:30 UTC
Spoke too soon.  XMLLayout did not call appendEscapingCDATA on NDC or throwable content.  Added new 
unit tests and fixed XMLLayout in rev 568774.  XSLTLayout handled situation properly, but added same 
tests to its test suite in 568775.