Commit ebc05c5a authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Avoid spurious output on standard error on malformed XML files.

parent b45c9f22
......@@ -27,6 +27,7 @@ import java.util.SortedSet;
import java.util.function.Supplier;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.hipparchus.exception.LocalizedCoreFormats;
......@@ -41,7 +42,6 @@ import org.orekit.utils.units.Unit;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
/** Loader for IERS rapid data and prediction file in XML format (finals file).
......@@ -119,14 +119,12 @@ class RapidDataAndPredictionXMLLoader extends AbstractEopLoader
throws IOException, OrekitException {
try {
this.history = new ArrayList<>();
// set up a reader for line-oriented bulletin B files
final XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
reader.setContentHandler(new EOPContentHandler(name));
// disable external entities
reader.setEntityResolver((publicId, systemId) -> new InputSource());
// set up a parser for line-oriented bulletin B files
final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
// read all file, ignoring header
reader.parse(new InputSource(new InputStreamReader(input, StandardCharsets.UTF_8)));
parser.parse(new InputSource(new InputStreamReader(input, StandardCharsets.UTF_8)),
new EOPContentHandler(name));
return history;
......@@ -448,6 +446,13 @@ class RapidDataAndPredictionXMLLoader extends AbstractEopLoader
}
}
/** {@inheritDoc} */
@Override
public InputSource resolveEntity(final String publicId, final String systemId) {
// disable external entities
return new InputSource();
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment