Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 708b22e4 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #142: [EDELIVERY-13369] add scheme validation for the sample extension

Merge in EDELIVERY/smp from bugfix/EDELIVERY-13369-sa-domismp-it3-3.5-cross-site-scripting-dom-and-3.8-open-redirect to development

* commit '6c177cca':
  [EDELIVERY-13369] add scheme validation for the sample extension
parents 70979e12 6c177cca
No related branches found
No related tags found
No related merge requests found
......@@ -67,11 +67,8 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
try {
factory.setFeature(DISALLOW_DOCTYPE_FEATURE, true);
} catch (ParserConfigurationException e) {
LOG.warn("DocumentBuilderFactory initialization error. The feature [{}] is not supported by current factory. The feature is ignored.", DISALLOW_DOCTYPE_FEATURE);
}
enableFeature(factory, DISALLOW_DOCTYPE_FEATURE);
enableFeature(factory, XMLConstants.FEATURE_SECURE_PROCESSING);
try {
return factory.newDocumentBuilder();
......@@ -80,6 +77,16 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
}
}
private static boolean enableFeature(DocumentBuilderFactory factory, String feature) {
try {
factory.setFeature(feature, true);
return true;
} catch (ParserConfigurationException e) {
LOG.warn("DocumentBuilderFactory initialization error. The feature [{}] is not supported by current factory. The feature is ignored.", feature);
return false;
}
}
private static final ThreadLocal<Unmarshaller> jaxbUnmarshaller = ThreadLocal.withInitial(() -> {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(CPP.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment