Mercurial > hg > release > icedtea7-forest-2.3 > jaxp
changeset 614:87860ab06231
8028111: XML readers share the same entity expansion counter
Reviewed-by: joehw, robm
author | coffeys |
---|---|
date | Fri, 21 Mar 2014 18:33:01 +0000 |
parents | 691a5e0c657f |
children | 0eb202593710 |
files | src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java |
diffstat | 6 files changed, 62 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Jan 14 20:24:45 2014 -0500 +++ b/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Fri Mar 21 18:33:01 2014 +0000 @@ -82,7 +82,12 @@ HashMap properties = propertyManager.getProperties(); supportedProps.putAll(properties); - fSecurityManager = (XMLSecurityManager)getProperty(SECURITY_MANAGER); + Object temp = getProperty(SECURITY_MANAGER); + //writers have no need for the managers + if (temp != null) { + fSecurityManager = new XMLSecurityManager((XMLSecurityManager)temp); + supportedProps.put(SECURITY_MANAGER, fSecurityManager); + } } private HashMap getProperties(){ @@ -173,9 +178,9 @@ * It's possible for users to set a security manager through the interface. * If it's the old SecurityManager, convert it to the new XMLSecurityManager */ - if (property.equals(Constants.SECURITY_MANAGER)) { + if (property.equals(SECURITY_MANAGER)) { fSecurityManager = XMLSecurityManager.convert(value, fSecurityManager); - supportedProps.put(Constants.SECURITY_MANAGER, fSecurityManager); + supportedProps.put(SECURITY_MANAGER, fSecurityManager); return; }
--- a/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Tue Jan 14 20:24:45 2014 -0500 +++ b/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Fri Mar 21 18:33:01 2014 +0000 @@ -682,6 +682,7 @@ XMLSecurityManager securityManager = (XMLSecurityManager) fComponentManager.getProperty(SECURITY_MANAGER); if (securityManager != null) { try { + securityManager.resetLimits(); reader.setProperty(SECURITY_MANAGER, securityManager); } // Ignore the exception if the security manager cannot be set.
--- a/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Jan 14 20:24:45 2014 -0500 +++ b/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Fri Mar 21 18:33:01 2014 +0000 @@ -415,6 +415,9 @@ fSchemaValidator.reset(this); // Mark configuration as fixed. fConfigUpdated = false; + if (fInitSecurityManager != null) { + fInitSecurityManager.resetLimits(); + } } void setErrorHandler(ErrorHandler errorHandler) {
--- a/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java Tue Jan 14 20:24:45 2014 -0500 +++ b/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java Fri Mar 21 18:33:01 2014 +0000 @@ -142,6 +142,9 @@ * reset all components before parsing */ protected void reset() throws XNIException { + if (securityManager != null) { + securityManager.resetLimits(); + } } // reset() } // class XMLParser
--- a/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java Tue Jan 14 20:24:45 2014 -0500 +++ b/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java Fri Mar 21 18:33:01 2014 +0000 @@ -110,6 +110,18 @@ } /** + * Reset all limits to their default status + */ + public void reset() { + for (int i=0; i<Limit.values().length; i++) { + values[i] = 0; + totalValue[i] = 0; + names[i] = null; + caches[i] = null; + } + } + + /** * Add the value to the current max count for the specified property * To find the max value of all entities, set no limit *
--- a/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Jan 14 20:24:45 2014 -0500 +++ b/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Fri Mar 21 18:33:01 2014 +0000 @@ -132,7 +132,7 @@ /** * Values of the properties */ - private final int[] values; + private int[] values; /** * States of the settings for each property */ @@ -169,10 +169,7 @@ * @param secureProcessing */ public XMLSecurityManager(boolean secureProcessing) { - limitAnalyzer = new XMLLimitAnalyzer(this); - values = new int[Limit.values().length]; - states = new State[Limit.values().length]; - isSet = new boolean[Limit.values().length]; + init(); this.secureProcessing = secureProcessing; for (Limit limit : Limit.values()) { if (secureProcessing) { @@ -188,6 +185,39 @@ } /** + * Clone a security manager + * @param securityManager a base security manager + */ + public XMLSecurityManager(XMLSecurityManager securityManager) { + init(); + if (securityManager != null) { + this.secureProcessing = securityManager.isSecureProcessing(); + for (Limit limit : Limit.values()) { + values[limit.ordinal()] = securityManager.getLimit(limit); + states[limit.ordinal()] = securityManager.getState(limit); + } + } + } + + /** + * Initialize values + */ + private void init() { + limitAnalyzer = new XMLLimitAnalyzer(this); + int numOfElements = Limit.values().length; + values = new int[numOfElements]; + states = new State[numOfElements]; + isSet = new boolean[numOfElements]; + } + + /** + * Reset all limits to their default status + */ + public void resetLimits() { + limitAnalyzer.reset(); + } + + /** * Setting FEATURE_SECURE_PROCESSING explicitly */ public void setSecureProcessing(boolean secure) {