DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22054>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22054

It's possible to create a text node with a null byte, resulting in erratic behavior

           Summary: It's possible to create a text node with a null byte,
                    resulting in erratic behavior
           Product: Xerces2-J
           Version: 2.4.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


This causes an exception (sounds correct to me):
    DocumentBuilderFactory dbf;
    DocumentBuilder db;
    Document d;
    Element root;
    
    dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true); 
    dbf.setAttribute("http://apache.org/xml/features/validation/dynamic";,
                    new Boolean(true));
    dbf.setAttribute("http://apache.org/xml/features/validation/schema";, 
                     new Boolean(true));
    
    db = dbf.newDocumentBuilder();
    d = db.parse(new InputSource(new StringReader("<root>Test\0</root>")));


This does not cause an exception:
    DocumentBuilderFactory dbf;
    DocumentBuilder db;
    Document d;
    Element root;
    org.w3c.dom.Text text;
    
    dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true); 
    dbf.setAttribute("http://apache.org/xml/features/validation/dynamic";,
                    new Boolean(true));
    dbf.setAttribute("http://apache.org/xml/features/validation/schema";, 
                     new Boolean(true));
    
    db = dbf.newDocumentBuilder();
    d = db.newDocument();
    root = d.createElement("root");
    d.appendChild(root);
    text = d.createTextNode("Test\0");
    root.appendChild(text);

As a result, you have an incorrect XML. If you try to output it via the
serializer, you get the error.

In another case, where I do not have a small repro yet, it would encode the null
byte but destroy the XML.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to