--- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java 2019-01-25 09:54:39.002982603 -0800 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java 2019-01-25 09:54:38.260914879 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. */ /* @@ -73,7 +73,7 @@ * @author Eric Ye, IBM * @author Sunitha Reddy, SUN Microsystems * - * @LastModified: Sep 2017 + * @LastModified: Jan 2019 */ public class XMLDocumentFragmentScannerImpl extends XMLScanner @@ -163,6 +163,10 @@ protected static final String STANDARD_URI_CONFORMANT = Constants.XERCES_FEATURE_PREFIX +Constants.STANDARD_URI_CONFORMANT_FEATURE; + /** Feature id: create entity ref nodes. */ + protected static final String CREATE_ENTITY_REF_NODES = + Constants.XERCES_FEATURE_PREFIX + Constants.CREATE_ENTITY_REF_NODES_FEATURE; + /** Property identifier: Security property manager. */ private static final String XML_SECURITY_PROPERTY_MANAGER = Constants.XML_SECURITY_PROPERTY_MANAGER; @@ -322,6 +326,9 @@ /** Xerces Feature: Disallow doctype declaration. */ protected boolean fDisallowDoctype = false; + /** Create entity reference nodes. */ + protected boolean fCreateEntityRefNodes = false; + /** * CDATA chunk size limit */ @@ -596,6 +603,8 @@ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null); fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false); + fCreateEntityRefNodes = componentManager.getFeature(CREATE_ENTITY_REF_NODES, fCreateEntityRefNodes); + Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null); fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ? (ExternalSubsetResolver) resolver : null; @@ -1837,14 +1846,20 @@ } else reportFatalError("EntityNotDeclared", new Object[]{name}); } - //we are starting the entity even if the entity was not declared - //if that was the case it its taken care in XMLEntityManager.startEntity() - //we immediately call the endEntity. Application gets to know if there was - //any entity that was not declared. - fEntityManager.startEntity(true, name, false); - //set the scaner state to content.. parser will automatically revive itself at any point of time. - //setScannerState(SCANNER_STATE_CONTENT); - //return true ; + + // create EntityReference only + if (fCreateEntityRefNodes) { + fDocumentHandler.startGeneralEntity(name, null, null, null); + } else { + //we are starting the entity even if the entity was not declared + //if that was the case it its taken care in XMLEntityManager.startEntity() + //we immediately call the endEntity. Application gets to know if there was + //any entity that was not declared. + fEntityManager.startEntity(true, name, false); + //set the scaner state to content.. parser will automatically revive itself at any point of time. + //setScannerState(SCANNER_STATE_CONTENT); + //return true ; + } } // scanEntityReference() // utility methods