JDK-6716312 : Data corruption in saxparser, chars outside XML passed to sax.helpers.DefaultHandler.characters()
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.parsers
  • Affected Version: 1.1,6u5
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows,windows_xp
  • CPU: x86
  • Submitted: 2008-06-18
  • Updated: 2014-10-28
  • Resolved: 2014-10-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Duplicate :  
Description
// Test program to demonstrate a data corruption error in SAXParser.
//
// 2008-06-18 Christian d'Heureuse, ###@###.###, www.source-code.biz
//
// Environments tested in which the error occurs:
//  1.6.0_10-beta-b25 Windows XP SP2        (includes Xerces 2.6.2)
//  1.6.0_06-b02      Windows XP SP2        (includes Xerces 2.6.2)
//  1.6.0_05-b13      Windows XP SP2        (includes Xerces 2.6.2)
//
// Environments tested in which the error does not occur:
//  1.6.0_10-beta-b25 Windows XP SP2  with Xerces snapshot 2008-06-15 (file xml-parser-gump-15062008.jar)
//  1.6.0_10-beta-b25 Windows XP SP2  with Xerces 2.9.1
//  1.6.0_10-beta-b25 Windows XP SP2  with Xerces 2.8.1
//  1.5.0_10-b03      Linux                 (includes Xerces 2.6.2)
//
// (Note that the Xerces JAR file must be copied into the lib/endorsed
// directory, in order to override the Xerces classes of the Java library.
// It's not sufficient to include the JAR file in the classpath.)

import java.io.File;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.helpers.DefaultHandler;

public class SaxParserError extends DefaultHandler {

private static final String inputFileName = "SaxParserError.xml";
private static final String testPattern   = "column-data";

public static void main (String args[]) throws Exception {
   SAXParser saxParser;
   SAXParserFactory factory = SAXParserFactory.newInstance();
   factory.setValidating(false);
   saxParser = factory.newSAXParser();
   saxParser.parse(new File(inputFileName), new SaxParserError());
   System.out.println ("OK, no error detected."); }

public void characters(char buf[], int offset, int len) {
   String s = new String(buf, offset, len);
   if (s.contains(testPattern)) {
      System.out.println ("Data corruption error detected.");
      System.exit (9); }}

} // end class SaxParserError
Regression from 1.5, broken in 6u1 - 6u10


I have found a data corruption error in SAXParser.

A test program and the XML data file to reproduce the error is at:
http://www.source-code.biz/snippets/java/saxParserError/

The error occurs with the SAXParser version included in JDK 1.6.0_10-beta-b25 (and other 1.6 versions), but not with the SAXParser of Xerces 2.9.1. It also does not occur with JDK 1.5.

The XML file used to reproduce this error is relatively big (86k). We tried to reduce it's size, but small changes on the XML file change the symptoms of the error.

The error is that characters from outside the text content of the XML elements are passed through org.xml.sax.helpers.DefaultHandler.characters().
Fragments from the XML file structure occur as element content text character

Comments
This issue has been fixed through JDK-8027359.
28-10-2014