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=4026>.
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=4026

usage of unparsed entity causes NullPointerException

           Summary: usage of unparsed entity causes NullPointerException
           Product: Xerces-J
           Version: 1.4.3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The usage of an unparsed external entity always causes a NullPointerException.  
To reproduce, use the DOMParser to attempt to parse any XML file that contains 
an inline DOCTYPE that contains an unparsed entity.  It makes no difference 
whether or not the entity is referenced in the DOM.  Here's a simple sample 
that reproduces the problem:

<!DOCTYPE UnparsedEntityTest [
        <!NOTATION xsd SYSTEM "xsd">
        <!ENTITY xsd1075 PUBLIC "EntityTest.xsd" "1075" NDATA xsd>
]>
<UnparsedEntityTest/>

The problem is in org.apache.xerces.readers.DefaultEntityHandler.java in the 
reference to a null member variable fSystemId in addExternalEntityDecl, 
addUnparsedEntityDecl, and addNotationDecl. Here's a new version of these 
functions that fixes the problem:

    public int addExternalEntityDecl(int name, int publicId, int systemId, 
boolean isExternal) throws Exception {
                String aname=fStringPool.toString(name);
                int entityHandle = fEntityPool.addEntityDecl(name, -1, 
publicId, systemId, fStringPool.addSymbol(aname), -1, isExternal);
        return entityHandle;
    }
    public int addUnparsedEntityDecl(int name, int publicId, int systemId, int 
notationName, boolean isExternal) throws Exception {
                String aname=fStringPool.toString(name);
                int entityHandle = fEntityPool.addEntityDecl(name, -1, 
publicId, systemId, fStringPool.addSymbol(aname), notationName, isExternal);
        if (!fEntityPool.isNotationDeclared(notationName)) {
            Object[] args = { fStringPool.toString(name),
                              fStringPool.toString(notationName) };
            fEntityPool.addRequiredNotation(notationName,
                                            fErrorReporter.getLocator(),
                                            
XMLMessages.MSG_NOTATION_NOT_DECLARED_FOR_UNPARSED_ENTITYDECL,
                                            XMLMessages.VC_NOTATION_DECLARED,
                                            args);
        }
        return entityHandle;
    }
    public int addNotationDecl(int notationName, int publicId, int systemId, 
boolean isExternal) throws Exception {
                String aname=fStringPool.toString(notationName);
        int notationHandle = fEntityPool.addNotationDecl(notationName, 
publicId, systemId, fStringPool.addSymbol(aname), isExternal);
        return notationHandle;
    }

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

Reply via email to