HHH-13960 Add SAXReader sec features to match the defaults
This commit is contained in:
parent
60abc8aa76
commit
55e54795c3
|
@ -59,6 +59,14 @@ public final class XMLHelper {
|
||||||
|
|
||||||
public SAXReader createSAXReader(ErrorLogger errorLogger, EntityResolver entityResolver) {
|
public SAXReader createSAXReader(ErrorLogger errorLogger, EntityResolver entityResolver) {
|
||||||
SAXReader saxReader = new SAXReader();
|
SAXReader saxReader = new SAXReader();
|
||||||
|
try {
|
||||||
|
saxReader.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
|
||||||
|
saxReader.setFeature( "http://xml.org/sax/features/external-general-entities", false );
|
||||||
|
saxReader.setFeature( "http://xml.org/sax/features/external-parameter-entities", false );
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
saxReader.setMergeAdjacentText( true );
|
saxReader.setMergeAdjacentText( true );
|
||||||
saxReader.setValidation( true );
|
saxReader.setValidation( true );
|
||||||
saxReader.setErrorHandler( errorLogger );
|
saxReader.setErrorHandler( errorLogger );
|
||||||
|
|
|
@ -64,7 +64,11 @@ abstract class Ejb3XmlTestCase extends BaseUnitTestCase {
|
||||||
|
|
||||||
protected XMLContext getContext(InputStream is) throws Exception {
|
protected XMLContext getContext(InputStream is) throws Exception {
|
||||||
XMLContext xmlContext = new XMLContext( BootstrapContextImpl.INSTANCE );
|
XMLContext xmlContext = new XMLContext( BootstrapContextImpl.INSTANCE );
|
||||||
Document doc = new SAXReader().read( is );
|
SAXReader reader = new SAXReader();
|
||||||
|
reader.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
|
||||||
|
reader.setFeature( "http://xml.org/sax/features/external-general-entities", false );
|
||||||
|
reader.setFeature( "http://xml.org/sax/features/external-parameter-entities", false );
|
||||||
|
Document doc = reader.read( is );
|
||||||
xmlContext.addDocument( doc );
|
xmlContext.addDocument( doc );
|
||||||
return xmlContext;
|
return xmlContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,13 @@ public class TestDataReader {
|
||||||
List<TestDataElement> testDataElements = new ArrayList<TestDataElement>();
|
List<TestDataElement> testDataElements = new ArrayList<TestDataElement>();
|
||||||
SAXReader reader = new SAXReader();
|
SAXReader reader = new SAXReader();
|
||||||
try {
|
try {
|
||||||
|
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
|
||||||
|
reader.setFeature("http://xml.org/sax/features/external-general-entities", false );
|
||||||
|
reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false );
|
||||||
Document document = reader.read( getInputStream( fileName ) );
|
Document document = reader.read( getInputStream( fileName ) );
|
||||||
addDataElements( document, testDataElements );
|
addDataElements( document, testDataElements );
|
||||||
}
|
}
|
||||||
catch (DocumentException e) {
|
catch (Exception e) {
|
||||||
throw new RuntimeException( e );
|
throw new RuntimeException( e );
|
||||||
}
|
}
|
||||||
return testDataElements;
|
return testDataElements;
|
||||||
|
|
Loading…
Reference in New Issue