Merge pull request #300 from mishako/xml-parser-feature-fix

Do not set unsupported XML parser features
This commit is contained in:
Patrick Gotthard 2016-05-01 12:42:11 +02:00
commit 3c681bd4ae

View file

@ -359,23 +359,29 @@ public class WireFeedInput {
}
} catch (final JDOMException e) {
throw new IllegalStateException("JDOM could not create a SAX parser");
throw new IllegalStateException("JDOM could not create a SAX parser", e);
}
saxBuilder.setExpandEntities(false);
return saxBuilder;
}
private void setFeature(SAXBuilder saxBuilder, XMLReader parser, String feature, boolean value) {
try {
if (isFeatureSupported(parser, feature, value)) {
saxBuilder.setFeature(feature, value);
}
}
private boolean isFeatureSupported(XMLReader parser, String feature, boolean value) {
try {
parser.setFeature(feature, value);
return true;
} catch (final SAXNotRecognizedException e) {
// ignore
return false;
} catch (final SAXNotSupportedException e) {
// ignore
return false;
}
}