aboutsummaryrefslogtreecommitdiff
path: root/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java')
-rw-r--r--src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java b/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
index e8e723a..b2460d9 100644
--- a/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
+++ b/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -128,18 +128,21 @@ public final class XMLLimitAnalyzer {
public void addValue(int index, String entityName, int value) {
if (index == Limit.ENTITY_EXPANSION_LIMIT.ordinal() ||
index == Limit.MAX_OCCUR_NODE_LIMIT.ordinal() ||
- index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal()) {
+ index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal() ||
+ index == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal()
+ ) {
totalValue[index] += value;
return;
}
- if (index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal()) {
+ if (index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal() ||
+ index == Limit.MAX_NAME_LIMIT.ordinal()) {
totalValue[index] = value;
return;
}
Map<String, Integer> cache;
if (caches[index] == null) {
- cache = new HashMap<String, Integer>(10);
+ cache = new HashMap<>(10);
caches[index] = cache;
} else {
cache = caches[index];
@@ -147,10 +150,10 @@ public final class XMLLimitAnalyzer {
int accumulatedValue = value;
if (cache.containsKey(entityName)) {
- accumulatedValue += cache.get(entityName).intValue();
- cache.put(entityName, Integer.valueOf(accumulatedValue));
+ accumulatedValue += cache.get(entityName);
+ cache.put(entityName, accumulatedValue);
} else {
- cache.put(entityName, Integer.valueOf(value));
+ cache.put(entityName, value);
}
if (accumulatedValue > values[index]) {
@@ -223,6 +226,16 @@ public final class XMLLimitAnalyzer {
}
}
+ /**
+ * Resets the current value of the specified limit.
+ * @param limit The limit to be reset.
+ */
+ public void reset(Limit limit) {
+ if (limit.ordinal() == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal()) {
+ totalValue[limit.ordinal()] = 0;
+ }
+ }
+
public void debugPrint(XMLSecurityManager securityManager) {
Formatter formatter = new Formatter();
System.out.println(formatter.format("%30s %15s %15s %15s %30s",