8147051: StaxEntityResolverWrapper should create StaxXMLInputSource with a resolver indicator

Reviewed-by: lancea
This commit is contained in:
Joe Wang 2016-01-15 20:56:15 -08:00
parent 07b44796c2
commit e07007fd51
4 changed files with 16 additions and 19 deletions

View file

@ -1155,7 +1155,7 @@ public class XMLDocumentScannerImpl
StaxXMLInputSource staxInputSource = fEntityManager.resolveEntityAsPerStax(resourceIdentifier); StaxXMLInputSource staxInputSource = fEntityManager.resolveEntityAsPerStax(resourceIdentifier);
// Check access permission. If the source is resolved by a resolver, the check is skipped. // 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); String accessError = checkAccess(fDoctypeSystemId, fAccessExternalDTD);
if (accessError != null) { if (accessError != null) {
reportFatalError("AccessExternalDTD", new Object[]{ SecuritySupport.sanitizePath(fDoctypeSystemId), accessError }); reportFatalError("AccessExternalDTD", new Object[]{ SecuritySupport.sanitizePath(fDoctypeSystemId), accessError });

View file

@ -1008,12 +1008,14 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
} }
// do default resolution // 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) { if (staxInputSource == null) {
// REVISIT: when systemId is null, I think we should return null. // REVISIT: when systemId is null, I think we should return null.
// is this the right solution? -SG // is this the right solution? -SG
//if (systemId != null) //if (systemId != null)
staxInputSource = new StaxXMLInputSource(new XMLInputSource(publicId, literalSystemId, baseSystemId)); staxInputSource = new StaxXMLInputSource(
new XMLInputSource(publicId, literalSystemId, baseSystemId), false);
}else if(staxInputSource.hasXMLStreamOrXMLEventReader()){ }else if(staxInputSource.hasXMLStreamOrXMLEventReader()){
//Waiting for the clarification from EG. - nb //Waiting for the clarification from EG. - nb
} }

View file

@ -71,12 +71,12 @@ public class StaxEntityResolverWrapper {
if(object == null) return null ; if(object == null) return null ;
if(object instanceof java.io.InputStream){ 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){ else if(object instanceof XMLStreamReader){
return new StaxXMLInputSource((XMLStreamReader)object) ; return new StaxXMLInputSource((XMLStreamReader)object, true) ;
}else if(object instanceof XMLEventReader){ }else if(object instanceof XMLEventReader){
return new StaxXMLInputSource((XMLEventReader)object) ; return new StaxXMLInputSource((XMLEventReader)object, true) ;
} }
return null ; return null ;

View file

@ -43,27 +43,22 @@ public class StaxXMLInputSource {
XMLEventReader fEventReader ; XMLEventReader fEventReader ;
XMLInputSource fInputSource ; XMLInputSource fInputSource ;
//indicate if the source is resolved by a resolver //indicates if the source is created by a resolver
boolean fHasResolver = false; boolean fIsCreatedByResolver = false;
/** Creates a new instance of StaxXMLInputSource */ /** Creates a new instance of StaxXMLInputSource */
public StaxXMLInputSource(XMLStreamReader streamReader) { public StaxXMLInputSource(XMLStreamReader streamReader, boolean byResolver) {
fStreamReader = streamReader ; fStreamReader = streamReader ;
} }
/** Creates a new instance of StaxXMLInputSource */ /** Creates a new instance of StaxXMLInputSource */
public StaxXMLInputSource(XMLEventReader eventReader) { public StaxXMLInputSource(XMLEventReader eventReader, boolean byResolver) {
fEventReader = eventReader ; fEventReader = eventReader ;
} }
public StaxXMLInputSource(XMLInputSource inputSource){ public StaxXMLInputSource(XMLInputSource inputSource, boolean byResolver){
fInputSource = inputSource ; fInputSource = inputSource ;
fIsCreatedByResolver = byResolver;
}
public StaxXMLInputSource(XMLInputSource inputSource, boolean hasResolver){
fInputSource = inputSource ;
fHasResolver = hasResolver;
} }
public XMLStreamReader getXMLStreamReader(){ public XMLStreamReader getXMLStreamReader(){
@ -82,7 +77,7 @@ public class StaxXMLInputSource {
return (fStreamReader == null) && (fEventReader == null) ? false : true ; return (fStreamReader == null) && (fEventReader == null) ? false : true ;
} }
public boolean hasResolver() { public boolean isCreatedByResolver() {
return fHasResolver; return fIsCreatedByResolver;
} }
} }