changeset 865:6aa4b1090a7c

8147051: StaxEntityResolverWrapper should create StaxXMLInputSource with a resolver indicator Reviewed-by: lancea
author joehw
date Fri, 15 Jan 2016 20:56:15 -0800
parents 9dcf193c0b6c
children 27704f0b5262
files src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java src/java.xml/share/classes/com/sun/xml/internal/stream/StaxXMLInputSource.java
diffstat 4 files changed, 16 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Thu Jan 14 12:03:08 2016 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Fri Jan 15 20:56:15 2016 -0800
@@ -1155,7 +1155,7 @@
                             StaxXMLInputSource staxInputSource =  fEntityManager.resolveEntityAsPerStax(resourceIdentifier);
 
                             // Check access permission. If the source is resolved by a resolver, the check is skipped.
-                            if (!staxInputSource.hasResolver()) {
+                            if (!staxInputSource.isCreatedByResolver()) {
                                 String accessError = checkAccess(fDoctypeSystemId, fAccessExternalDTD);
                                 if (accessError != null) {
                                     reportFatalError("AccessExternalDTD", new Object[]{ SecuritySupport.sanitizePath(fDoctypeSystemId), accessError });
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Thu Jan 14 12:03:08 2016 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Fri Jan 15 20:56:15 2016 -0800
@@ -1008,12 +1008,14 @@
         }
 
         // do default resolution
-        //this works for both stax & Xerces, if staxInputSource is null, it means parser need to revert to default resolution
+        //this works for both stax & Xerces, if staxInputSource is null,
+        //it means parser need to revert to default resolution
         if (staxInputSource == null) {
             // REVISIT: when systemId is null, I think we should return null.
             //          is this the right solution? -SG
             //if (systemId != null)
-            staxInputSource = new StaxXMLInputSource(new XMLInputSource(publicId, literalSystemId, baseSystemId));
+            staxInputSource = new StaxXMLInputSource(
+                    new XMLInputSource(publicId, literalSystemId, baseSystemId), false);
         }else if(staxInputSource.hasXMLStreamOrXMLEventReader()){
             //Waiting for the clarification from EG. - nb
         }
--- a/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java	Thu Jan 14 12:03:08 2016 -0800
+++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java	Fri Jan 15 20:56:15 2016 -0800
@@ -71,12 +71,12 @@
         if(object == null) return null ;
 
         if(object  instanceof java.io.InputStream){
-            return new StaxXMLInputSource(new XMLInputSource(null, null, null, (InputStream)object, null));
+            return new StaxXMLInputSource(new XMLInputSource(null, null, null, (InputStream)object, null), true);
         }
         else if(object instanceof XMLStreamReader){
-            return new StaxXMLInputSource((XMLStreamReader)object) ;
+            return new StaxXMLInputSource((XMLStreamReader)object, true) ;
         }else if(object instanceof XMLEventReader){
-            return new StaxXMLInputSource((XMLEventReader)object) ;
+            return new StaxXMLInputSource((XMLEventReader)object, true) ;
         }
 
         return null ;
--- a/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxXMLInputSource.java	Thu Jan 14 12:03:08 2016 -0800
+++ b/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxXMLInputSource.java	Fri Jan 15 20:56:15 2016 -0800
@@ -43,27 +43,22 @@
     XMLEventReader fEventReader ;
     XMLInputSource fInputSource ;
 
-    //indicate if the source is resolved by a resolver
-    boolean fHasResolver = false;
+    //indicates if the source is created by a resolver
+    boolean fIsCreatedByResolver = false;
 
     /** Creates a new instance of StaxXMLInputSource */
-    public StaxXMLInputSource(XMLStreamReader streamReader) {
+    public StaxXMLInputSource(XMLStreamReader streamReader, boolean byResolver) {
         fStreamReader = streamReader ;
     }
 
     /** Creates a new instance of StaxXMLInputSource */
-    public StaxXMLInputSource(XMLEventReader eventReader) {
+    public StaxXMLInputSource(XMLEventReader eventReader, boolean byResolver) {
         fEventReader = eventReader ;
     }
 
-    public StaxXMLInputSource(XMLInputSource inputSource){
+    public StaxXMLInputSource(XMLInputSource inputSource, boolean byResolver){
         fInputSource = inputSource ;
-
-    }
-
-    public StaxXMLInputSource(XMLInputSource inputSource, boolean hasResolver){
-        fInputSource = inputSource ;
-        fHasResolver = hasResolver;
+        fIsCreatedByResolver = byResolver;
     }
 
     public XMLStreamReader getXMLStreamReader(){
@@ -82,7 +77,7 @@
         return (fStreamReader == null) && (fEventReader == null) ? false : true ;
     }
 
-    public boolean hasResolver() {
-        return fHasResolver;
+    public boolean isCreatedByResolver() {
+        return fIsCreatedByResolver;
     }
 }