# HG changeset patch # User aefimov # Date 1441201203 -10800 # Node ID 76ead37867a5415352f01a53cf04556f44071f70 # Parent 41c6f1e54d42fb6c01c01db31f2ac57863a4ec1a 8133962: More general limits Reviewed-by: dfuchs, lancea, ahgross diff -r 41c6f1e54d42 -r 76ead37867a5 src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java --- 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); } } } diff -r 41c6f1e54d42 -r 76ead37867a5 src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java --- 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 diff -r 41c6f1e54d42 -r 76ead37867a5 src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java --- 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 diff -r 41c6f1e54d42 -r 76ead37867a5 src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java --- 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 diff -r 41c6f1e54d42 -r 76ead37867a5 src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java --- 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); } } } diff -r 41c6f1e54d42 -r 76ead37867a5 src/com/sun/xml/internal/stream/Entity.java --- 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;