Mercurial > hg > openjdk > jdk8u > jaxp
changeset 2044:de4f48e77477
8232014: Expand DTD support
Reviewed-by: lancea, dfuchs, mschoene, rhalade, aefimov
author | joehw |
---|---|
date | Sat, 11 Jul 2020 20:36:43 +0100 |
parents | 28bf66a33956 |
children | 63884b34cac1 |
files | src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java |
diffstat | 3 files changed, 21 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java Sat Jun 27 23:21:46 2020 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java Sat Jul 11 20:36:43 2020 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. */ /* @@ -71,6 +71,7 @@ * @author Eric Ye, IBM * * @version $Id: XMLDTDScannerImpl.java,v 1.8 2010-11-01 04:39:41 joehw Exp $ + * @LastModified: Feb 2020 */ public class XMLDTDScannerImpl extends XMLScanner @@ -615,6 +616,7 @@ if (fScannerState == SCANNER_STATE_END_OF_INPUT) return; + boolean dtdEntity = name.equals("[dtd]"); // Handle end of PE boolean reportEntity = fReportEntity; if (name.startsWith("%")) { @@ -623,8 +625,7 @@ int startMarkUpDepth = popPEStack(); // throw fatalError if this entity was incomplete and // was a freestanding decl - if(startMarkUpDepth == 0 && - startMarkUpDepth < fMarkUpDepth) { + if (startMarkUpDepth == 0 && startMarkUpDepth < fMarkUpDepth) { fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "ILL_FORMED_PARAMETER_ENTITY_WHEN_USED_IN_DECL", new Object[]{ fEntityManager.fCurrentEntity.name}, @@ -644,12 +645,10 @@ if (fEntityScanner.isExternal()) { fExtEntityDepth--; } - } - - // call handler - boolean dtdEntity = name.equals("[dtd]"); - if (fDTDHandler != null && !dtdEntity && reportEntity) { - fDTDHandler.endParameterEntity(name, null); + // call handler + if (fDTDHandler != null && reportEntity) { + fDTDHandler.endParameterEntity(name, null); + } } // end DTD
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Sat Jun 27 23:21:46 2020 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Sat Jul 11 20:36:43 2020 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. */ /* @@ -69,6 +69,7 @@ * @author K.Venugopal SUN Microsystems * @author Sunitha Reddy, SUN Microsystems * @version $Id: XMLScanner.java,v 1.12 2010-11-01 04:39:41 joehw Exp $ + * @LastModified: Feb 2020 */ public abstract class XMLScanner implements XMLComponent { @@ -1240,10 +1241,10 @@ * @throws XNIException Thrown by handler to signal an error. */ public void endEntity(String name, Augmentations augs) throws IOException, XNIException { - // keep track of the entity depth - fEntityDepth--; - + if (fEntityDepth > 0) { + fEntityDepth--; + } } // endEntity(String) /**
--- a/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java Sat Jun 27 23:21:46 2020 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java Sat Jul 11 20:36:43 2020 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -61,6 +61,7 @@ * @author Neil Graham, IBM * * @version $Id: DTDGrammar.java,v 1.4 2010/08/11 07:18:37 joehw Exp $ + * @LastModified: Feb 2020 */ public class DTDGrammar implements XMLDTDHandler, XMLDTDContentModelHandler, EntityState, Grammar { @@ -445,9 +446,12 @@ * @throws XNIException Thrown by handler to signal an error. */ public void endParameterEntity(String name, Augmentations augs) throws XNIException { - - fPEDepth--; - fReadingExternalDTD = fPEntityStack[fPEDepth]; + // redundant check as this method can only be called after parsing a PE + // incomplete or truncated DTD get caught before reaching this method + if (fPEDepth > 0) { + fPEDepth--; + fReadingExternalDTD = fPEntityStack[fPEDepth]; + } } // endParameterEntity(String,Augmentations)