changeset 1171:6568ef042ca5

8133962: More general limits Reviewed-by: dfuchs, lancea, ahgross
author aefimov
date Wed, 02 Sep 2015 16:40:03 +0300
parents 05d83d5f6999
children 6ca5a02ed7f3
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	Mon Aug 31 14:48:12 2015 -0700
+++ 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	Mon Aug 31 14:48:12 2015 -0700
+++ 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	Mon Aug 31 14:48:12 2015 -0700
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Wed Sep 02 16:40:03 2015 +0300
@@ -1106,7 +1106,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.
@@ -1114,7 +1114,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?
@@ -1238,7 +1238,7 @@
         }
 
         // start the entity
-        startEntity(reference, entityName, xmlInputSource, literal, external);
+        startEntity(isGE, entityName, xmlInputSource, literal, external);
 
     } // startEntity(String,boolean)
 
@@ -1287,7 +1287,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
@@ -1297,12 +1297,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	Mon Aug 31 14:48:12 2015 -0700
+++ 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);
         }
 
@@ -1205,6 +1205,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	Mon Aug 31 14:48:12 2015 -0700
+++ 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	Mon Aug 31 14:48:12 2015 -0700
+++ 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;