# HG changeset patch # User aefimov # Date 1453141815 0 # Node ID 8f8ebe87d57ac28a4a65e25badda0894524982ad # Parent b6d0c2cd0b173b78ede159bc1863ad672712250d 8133962: More general limits Reviewed-by: dfuchs, lancea, ahgross diff -r b6d0c2cd0b17 -r 8f8ebe87d57a drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java Fri Nov 13 01:28:32 2015 +0000 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java Mon Jan 18 18:30:15 2016 +0000 @@ -332,7 +332,7 @@ new Object[]{entityName}); } } - fEntityManager.startEntity(false, entityName, true); + fEntityManager.startEntity(true, entityName, true); } } } diff -r b6d0c2cd0b17 -r 8f8ebe87d57a drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java Fri Nov 13 01:28:32 2015 +0000 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java Mon Jan 18 18:30:15 2016 +0000 @@ -894,7 +894,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); @@ -1040,6 +1040,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 b6d0c2cd0b17 -r 8f8ebe87d57a drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Fri Nov 13 01:28:32 2015 +0000 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Mon Jan 18 18:30:15 2016 +0000 @@ -1116,7 +1116,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. @@ -1124,7 +1124,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? @@ -1243,7 +1243,7 @@ } // start the entity - startEntity(reference, entityName, xmlInputSource, literal, external); + startEntity(isGE, entityName, xmlInputSource, literal, external); } // startEntity(String,boolean) @@ -1292,7 +1292,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 @@ -1302,12 +1302,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 b6d0c2cd0b17 -r 8f8ebe87d57a drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java Fri Nov 13 01:28:32 2015 +0000 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java Mon Jan 18 18:30:15 2016 +0000 @@ -1001,7 +1001,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); } @@ -1177,6 +1177,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 b6d0c2cd0b17 -r 8f8ebe87d57a drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Fri Nov 13 01:28:32 2015 +0000 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Mon Jan 18 18:30:15 2016 +0000 @@ -963,7 +963,7 @@ new Object[]{entityName}); } } - fEntityManager.startEntity(false, entityName, true); + fEntityManager.startEntity(true, entityName, true); } } } diff -r b6d0c2cd0b17 -r 8f8ebe87d57a drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java --- a/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Fri Nov 13 01:28:32 2015 +0000 +++ b/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Mon Jan 18 18:30:15 2016 +0000 @@ -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;