changeset 1371:76ead37867a5

8133962: More general limits Reviewed-by: dfuchs, lancea, ahgross
author aefimov
date Wed, 02 Sep 2015 16:40:03 +0300
parents 41c6f1e54d42
children ab80a04a71a5
files src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java src/com/sun/xml/internal/stream/Entity.java
diffstat 6 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java	Fri Nov 13 02:43:40 2015 +0000
+++ b/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java	Wed Sep 02 16:40:03 2015 +0300
@@ -332,7 +332,7 @@
                                                          new Object[]{entityName});
                                     }
                                 }
-                                fEntityManager.startEntity(false, entityName, true);
+                                fEntityManager.startEntity(true, entityName, true);
                             }
                         }
                     }
--- a/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java	Fri Nov 13 02:43:40 2015 +0000
+++ b/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java	Wed Sep 02 16:40:03 2015 +0300
@@ -905,7 +905,7 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
-        if (fCurrentEntity.reference) {
+        if (fCurrentEntity.isGE) {
             checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
         }
         content.setValues(fCurrentEntity.ch, offset, length);
@@ -1052,6 +1052,9 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
+        if (fCurrentEntity.isGE) {
+            checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
+        }
         content.setValues(fCurrentEntity.ch, offset, length);
 
         // return next character
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Fri Nov 13 02:43:40 2015 +0000
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Wed Sep 02 16:40:03 2015 +0300
@@ -1105,7 +1105,7 @@
     /**
      * Starts a named entity.
      *
-     * @param reference flag to indicate whether the entity is an Entity Reference.
+     * @param isGE flag to indicate whether the entity is a General Entity
      * @param entityName The name of the entity to start.
      * @param literal    True if this entity is started within a literal
      *                   value.
@@ -1113,7 +1113,7 @@
      * @throws IOException  Thrown on i/o error.
      * @throws XNIException Thrown by entity handler to signal an error.
      */
-    public void startEntity(boolean reference, String entityName, boolean literal)
+    public void startEntity(boolean isGE, String entityName, boolean literal)
     throws IOException, XNIException {
 
         // was entity declared?
@@ -1237,7 +1237,7 @@
         }
 
         // start the entity
-        startEntity(reference, entityName, xmlInputSource, literal, external);
+        startEntity(isGE, entityName, xmlInputSource, literal, external);
 
     } // startEntity(String,boolean)
 
@@ -1286,7 +1286,7 @@
      * This method can be used to insert an application defined XML
      * entity stream into the parsing stream.
      *
-     * @param reference flag to indicate whether the entity is an Entity Reference.
+     * @param isGE flag to indicate whether the entity is a General Entity
      * @param name           The name of the entity.
      * @param xmlInputSource The input source of the entity.
      * @param literal        True if this entity is started within a
@@ -1296,12 +1296,12 @@
      * @throws IOException  Thrown on i/o error.
      * @throws XNIException Thrown by entity handler to signal an error.
      */
-    public void startEntity(boolean reference, String name,
+    public void startEntity(boolean isGE, String name,
             XMLInputSource xmlInputSource,
             boolean literal, boolean isExternal)
             throws IOException, XNIException {
 
-        String encoding = setupCurrentEntity(reference, name, xmlInputSource, literal, isExternal);
+        String encoding = setupCurrentEntity(isGE, name, xmlInputSource, literal, isExternal);
 
         //when entity expansion limit is set by the Application, we need to
         //check for the entity expansion limit set by the parser, if number of entity
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java	Fri Nov 13 02:43:40 2015 +0000
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java	Wed Sep 02 16:40:03 2015 +0300
@@ -1038,7 +1038,7 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
-        if (fCurrentEntity.reference) {
+        if (fCurrentEntity.isGE) {
             checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
         }
 
@@ -1215,6 +1215,9 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
+        if (fCurrentEntity.isGE) {
+            checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
+        }
         content.setValues(fCurrentEntity.ch, offset, length);
 
         // return next character
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Fri Nov 13 02:43:40 2015 +0000
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java	Wed Sep 02 16:40:03 2015 +0300
@@ -947,7 +947,7 @@
                                                 new Object[]{entityName});
                                     }
                                 }
-                                fEntityManager.startEntity(false, entityName, true);
+                                fEntityManager.startEntity(true, entityName, true);
                             }
                         }
                     }
--- a/src/com/sun/xml/internal/stream/Entity.java	Fri Nov 13 02:43:40 2015 +0000
+++ b/src/com/sun/xml/internal/stream/Entity.java	Wed Sep 02 16:40:03 2015 +0300
@@ -344,8 +344,8 @@
         // to know that prolog is read
         public boolean xmlDeclChunkRead = false;
 
-        // flag to indicate whether the Entity is an Entity Reference
-        public boolean reference = false;
+        // flag to indicate whether the Entity is a General Entity
+        public boolean isGE = false;
 
         /** returns the name of the current encoding
          *  @return current encoding name
@@ -391,11 +391,11 @@
         //
 
         /** Constructs a scanned entity. */
-        public ScannedEntity(boolean reference, String name,
+        public ScannedEntity(boolean isGE, String name,
                 XMLResourceIdentifier entityLocation,
                 InputStream stream, Reader reader,
                 String encoding, boolean literal, boolean mayReadChunks, boolean isExternal) {
-            this.reference = reference;
+            this.isGE = isGE;
             this.name = name ;
             this.entityLocation = entityLocation;
             this.stream = stream;