Merge pull request #359 from subhrajyotim/master

Fix: Add null check in JsonParser, Relax property handling introduced in Jaxp 1.5
This commit is contained in:
James Agnew 2016-05-05 07:09:06 -04:00
commit 03e90b90c0
2 changed files with 18 additions and 11 deletions

View File

@ -1026,7 +1026,7 @@ public class JsonParser extends BaseParser implements IParser {
private JsonArray grabJsonArray(JsonObject theObject, String nextName, String thePosition) {
JsonValue object = theObject.get(nextName);
if (object == null) {
if (object == null || object.getValueType()==ValueType.NULL) {
return null;
}
if (object.getValueType() != ValueType.ARRAY) {

View File

@ -44,6 +44,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSResourceResolver;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXParseException;
import ca.uhn.fhir.context.ConfigurationException;
@ -93,12 +94,16 @@ public class SchemaBaseValidator implements IValidatorModule {
encodedResource = theContext.getFhirContext().newXmlParser().encodeResourceToString((IBaseResource) theContext.getResource());
}
try {
/*
* See https://github.com/jamesagnew/hapi-fhir/issues/339
* https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing
*/
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
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)));
} catch (SAXParseException e) {
@ -132,13 +137,15 @@ public class SchemaBaseValidator implements IValidatorModule {
schemaFactory.setResourceResolver(new MyResourceResolver());
try {
try {
/*
* See https://github.com/jamesagnew/hapi-fhir/issues/339
* 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 });
} catch (SAXException e) {
throw new ConfigurationException("Could not load/parse schema file: " + theSchemaName, e);