Skip to content

Commit 563be81

Browse files
committed
disable JAXP FEATURE_SECURE_PROCESSING
1 parent 33da7fb commit 563be81

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/test/java/fr/jmmc/oitools/OIFitsViewerTest.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,31 @@ public void existDB_check() throws IOException, FitsException {
102102
public void existDB_to_xml() throws IOException, FitsException {
103103
for (String fileName : OIFITS_FILENAME) {
104104
try {
105-
final String result = existDB_process(TEST_DIR_OIFITS + fileName, true);
106-
logger.log(Level.INFO, "existDB_to_xml:\n{0}", result);
105+
final String outputXML = existDB_process(TEST_DIR_OIFITS + fileName, true);
106+
logger.log(Level.INFO, "existDB_to_xml:\n{0}", outputXML);
107107

108+
DocumentBuilderFactory dBF = null;
108109
try {
109-
DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
110-
DocumentBuilder builder = dBF.newDocumentBuilder();
111-
InputSource is = new InputSource(new StringReader(result));
112-
builder.parse(is);
110+
dBF = DocumentBuilderFactory.newInstance();
111+
// Disable secure processing (no limits):
112+
dBF.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, false);
113113
} catch (ParserConfigurationException ex) {
114114
logger.log(Level.INFO, "existDB_to_xml:", ex);
115115
// do not consider this case as a faulty xml output
116-
} catch (SAXException ex) {
117-
logger.log(Level.INFO, "existDB_to_xml:", ex);
118-
Assert.fail("OIFitsViewer xml output is not well formed");
119116
}
120-
117+
if (dBF != null) {
118+
try {
119+
DocumentBuilder builder = dBF.newDocumentBuilder();
120+
InputSource is = new InputSource(new StringReader(outputXML));
121+
builder.parse(is);
122+
} catch (ParserConfigurationException ex) {
123+
logger.log(Level.INFO, "existDB_to_xml:", ex);
124+
// do not consider this case as a faulty xml output
125+
} catch (SAXException ex) {
126+
logger.log(Level.INFO, "existDB_to_xml:", ex);
127+
Assert.fail("OIFitsViewer xml output is not well formed");
128+
}
129+
}
121130
} catch (RuntimeException re) {
122131
logger.log(Level.INFO, "existDB_to_xml:", re);
123132
// unexpected

0 commit comments

Comments
 (0)