jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
changeset 17534 21dc0b2762da
parent 12458 d601e4bba306
child 17538 d8d911c4e5d4
equal deleted inserted replaced
17533:93a2cadbbd33 17534:21dc0b2762da
    24 import java.util.ArrayList;
    24 import java.util.ArrayList;
    25 import java.util.Enumeration;
    25 import java.util.Enumeration;
    26 import java.util.Locale;
    26 import java.util.Locale;
    27 import java.util.Stack;
    27 import java.util.Stack;
    28 import java.util.StringTokenizer;
    28 import java.util.StringTokenizer;
       
    29 import javax.xml.XMLConstants;
    29 
    30 
    30 import com.sun.org.apache.xerces.internal.impl.Constants;
    31 import com.sun.org.apache.xerces.internal.impl.Constants;
    31 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
    32 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
    32 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
    33 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
    33 import com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException;
    34 import com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException;
   227         Constants.XERCES_PROPERTY_PREFIX + Constants.BUFFER_SIZE_PROPERTY;
   228         Constants.XERCES_PROPERTY_PREFIX + Constants.BUFFER_SIZE_PROPERTY;
   228 
   229 
   229     protected static final String PARSER_SETTINGS =
   230     protected static final String PARSER_SETTINGS =
   230         Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
   231         Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
   231 
   232 
       
   233     /** property identifier: access external dtd. */
       
   234     protected static final String ACCESS_EXTERNAL_DTD = XMLConstants.ACCESS_EXTERNAL_DTD;
       
   235 
       
   236     /** access external dtd: file protocol
       
   237      *  For DOM/SAX, the secure feature is set to true by default
       
   238      */
       
   239     final static String EXTERNAL_ACCESS_DEFAULT = Constants.EXTERNAL_ACCESS_DEFAULT;
       
   240 
   232     /** Recognized features. */
   241     /** Recognized features. */
   233     private static final String[] RECOGNIZED_FEATURES =
   242     private static final String[] RECOGNIZED_FEATURES =
   234         { ALLOW_UE_AND_NOTATION_EVENTS, XINCLUDE_FIXUP_BASE_URIS, XINCLUDE_FIXUP_LANGUAGE };
   243         { ALLOW_UE_AND_NOTATION_EVENTS, XINCLUDE_FIXUP_BASE_URIS, XINCLUDE_FIXUP_LANGUAGE };
   235 
   244 
   236     /** Feature defaults. */
   245     /** Feature defaults. */
   281     protected XIncludeNamespaceSupport fNamespaceContext;
   290     protected XIncludeNamespaceSupport fNamespaceContext;
   282     protected SymbolTable fSymbolTable;
   291     protected SymbolTable fSymbolTable;
   283     protected XMLErrorReporter fErrorReporter;
   292     protected XMLErrorReporter fErrorReporter;
   284     protected XMLEntityResolver fEntityResolver;
   293     protected XMLEntityResolver fEntityResolver;
   285     protected SecurityManager fSecurityManager;
   294     protected SecurityManager fSecurityManager;
       
   295     /**
       
   296      * comma-delimited list of protocols that are allowed for the purpose
       
   297      * of accessing external dtd or entity references
       
   298      */
       
   299     protected String fAccessExternalDTD = EXTERNAL_ACCESS_DEFAULT;
       
   300 
   286 
   301 
   287     // these are needed for text include processing
   302     // these are needed for text include processing
   288     protected XIncludeTextReader fXInclude10TextReader;
   303     protected XIncludeTextReader fXInclude10TextReader;
   289     protected XIncludeTextReader fXInclude11TextReader;
   304     protected XIncludeTextReader fXInclude11TextReader;
   290 
   305 
   520             }
   535             }
   521         }
   536         }
   522         catch (XMLConfigurationException e) {
   537         catch (XMLConfigurationException e) {
   523             fSecurityManager = null;
   538             fSecurityManager = null;
   524         }
   539         }
       
   540 
       
   541         fAccessExternalDTD = (String)componentManager.getProperty(ACCESS_EXTERNAL_DTD);
   525 
   542 
   526         // Get buffer size.
   543         // Get buffer size.
   527         try {
   544         try {
   528             Integer value =
   545             Integer value =
   529                 (Integer)componentManager.getProperty(
   546                 (Integer)componentManager.getProperty(
   662             if (fChildConfig != null) {
   679             if (fChildConfig != null) {
   663                 fChildConfig.setProperty(propertyId, value);
   680                 fChildConfig.setProperty(propertyId, value);
   664             }
   681             }
   665             return;
   682             return;
   666         }
   683         }
       
   684         if (propertyId.equals(ACCESS_EXTERNAL_DTD)) {
       
   685             fAccessExternalDTD = (String)value;
       
   686             if (fChildConfig != null) {
       
   687                 fChildConfig.setProperty(propertyId, value);
       
   688             }
       
   689             return;
       
   690         }
       
   691 
   667         if (propertyId.equals(BUFFER_SIZE)) {
   692         if (propertyId.equals(BUFFER_SIZE)) {
   668             Integer bufferSize = (Integer) value;
   693             Integer bufferSize = (Integer) value;
   669             if (fChildConfig != null) {
   694             if (fChildConfig != null) {
   670                 fChildConfig.setProperty(propertyId, value);
   695                 fChildConfig.setProperty(propertyId, value);
   671             }
   696             }
  1576                 // use the same symbol table, error reporter, entity resolver, security manager and buffer size.
  1601                 // use the same symbol table, error reporter, entity resolver, security manager and buffer size.
  1577                 if (fSymbolTable != null) fChildConfig.setProperty(SYMBOL_TABLE, fSymbolTable);
  1602                 if (fSymbolTable != null) fChildConfig.setProperty(SYMBOL_TABLE, fSymbolTable);
  1578                 if (fErrorReporter != null) fChildConfig.setProperty(ERROR_REPORTER, fErrorReporter);
  1603                 if (fErrorReporter != null) fChildConfig.setProperty(ERROR_REPORTER, fErrorReporter);
  1579                 if (fEntityResolver != null) fChildConfig.setProperty(ENTITY_RESOLVER, fEntityResolver);
  1604                 if (fEntityResolver != null) fChildConfig.setProperty(ENTITY_RESOLVER, fEntityResolver);
  1580                 fChildConfig.setProperty(SECURITY_MANAGER, fSecurityManager);
  1605                 fChildConfig.setProperty(SECURITY_MANAGER, fSecurityManager);
       
  1606                 fChildConfig.setProperty(ACCESS_EXTERNAL_DTD, fAccessExternalDTD);
  1581                 fChildConfig.setProperty(BUFFER_SIZE, new Integer(fBufferSize));
  1607                 fChildConfig.setProperty(BUFFER_SIZE, new Integer(fBufferSize));
  1582 
  1608 
  1583                 // features must be copied to child configuration
  1609                 // features must be copied to child configuration
  1584                 fNeedCopyFeatures = true;
  1610                 fNeedCopyFeatures = true;
  1585 
  1611 
  1689             catch (XNIException e) {
  1715             catch (XNIException e) {
  1690                 // necessary to make sure proper location is reported in errors
  1716                 // necessary to make sure proper location is reported in errors
  1691                 if (fErrorReporter != null) {
  1717                 if (fErrorReporter != null) {
  1692                     fErrorReporter.setDocumentLocator(fDocLocation);
  1718                     fErrorReporter.setDocumentLocator(fDocLocation);
  1693                 }
  1719                 }
  1694                 reportFatalError("XMLParseError", new Object[] { href });
  1720                 reportFatalError("XMLParseError", new Object[] { href, e.getMessage() });
  1695             }
  1721             }
  1696             catch (IOException e) {
  1722             catch (IOException e) {
  1697                 // necessary to make sure proper location is reported in errors
  1723                 // necessary to make sure proper location is reported in errors
  1698                 if (fErrorReporter != null) {
  1724                 if (fErrorReporter != null) {
  1699                     fErrorReporter.setDocumentLocator(fDocLocation);
  1725                     fErrorReporter.setDocumentLocator(fDocLocation);