Fix: Add null check in JsonParser, Relax property handling introduced in Jaxp 1.5 for some compatibility with existing 1.4 version
This commit is contained in:
parent
804b271764
commit
284f0f14b0
|
@ -1026,7 +1026,7 @@ public class JsonParser extends BaseParser implements IParser {
|
||||||
|
|
||||||
private JsonArray grabJsonArray(JsonObject theObject, String nextName, String thePosition) {
|
private JsonArray grabJsonArray(JsonObject theObject, String nextName, String thePosition) {
|
||||||
JsonValue object = theObject.get(nextName);
|
JsonValue object = theObject.get(nextName);
|
||||||
if (object == null) {
|
if (object == null || object.getValueType()==ValueType.NULL) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (object.getValueType() != ValueType.ARRAY) {
|
if (object.getValueType() != ValueType.ARRAY) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.w3c.dom.ls.LSInput;
|
import org.w3c.dom.ls.LSInput;
|
||||||
import org.w3c.dom.ls.LSResourceResolver;
|
import org.w3c.dom.ls.LSResourceResolver;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.SAXNotRecognizedException;
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
@ -93,12 +94,16 @@ public class SchemaBaseValidator implements IValidatorModule {
|
||||||
encodedResource = theContext.getFhirContext().newXmlParser().encodeResourceToString((IBaseResource) theContext.getResource());
|
encodedResource = theContext.getFhirContext().newXmlParser().encodeResourceToString((IBaseResource) theContext.getResource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
/*
|
/*
|
||||||
* See https://github.com/jamesagnew/hapi-fhir/issues/339
|
* See https://github.com/jamesagnew/hapi-fhir/issues/339
|
||||||
* https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing
|
* https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing
|
||||||
*/
|
*/
|
||||||
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
||||||
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
|
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
|
||||||
|
}catch (SAXNotRecognizedException ex){
|
||||||
|
ourLog.warn("Jaxp 1.5 Support not found.",ex);
|
||||||
|
}
|
||||||
|
|
||||||
validator.validate(new StreamSource(new StringReader(encodedResource)));
|
validator.validate(new StreamSource(new StringReader(encodedResource)));
|
||||||
} catch (SAXParseException e) {
|
} catch (SAXParseException e) {
|
||||||
|
@ -132,13 +137,15 @@ public class SchemaBaseValidator implements IValidatorModule {
|
||||||
schemaFactory.setResourceResolver(new MyResourceResolver());
|
schemaFactory.setResourceResolver(new MyResourceResolver());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
/*
|
/*
|
||||||
* See https://github.com/jamesagnew/hapi-fhir/issues/339
|
* See https://github.com/jamesagnew/hapi-fhir/issues/339
|
||||||
* https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing
|
* https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing
|
||||||
*/
|
*/
|
||||||
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
||||||
|
}catch (SAXNotRecognizedException snex){
|
||||||
|
ourLog.warn("Jaxp 1.5 Support not found.",snex);
|
||||||
|
}
|
||||||
schema = schemaFactory.newSchema(new Source[] { baseSource });
|
schema = schemaFactory.newSchema(new Source[] { baseSource });
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
throw new ConfigurationException("Could not load/parse schema file: " + theSchemaName, e);
|
throw new ConfigurationException("Could not load/parse schema file: " + theSchemaName, e);
|
||||||
|
|
Loading…
Reference in New Issue