Ignore:
Timestamp:
2018-06-08T22:43:20+02:00 (6 years ago)
Author:
Don-vip
Message:

add new XmlUtils class with more "safe factories" methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/preferences/PreferencesReader.java

    r13715 r13901  
    2121
    2222import javax.xml.XMLConstants;
    23 import javax.xml.stream.XMLInputFactory;
    2423import javax.xml.stream.XMLStreamConstants;
    2524import javax.xml.stream.XMLStreamException;
     
    3736import org.openstreetmap.josm.spi.preferences.StringSetting;
    3837import org.openstreetmap.josm.tools.Logging;
    39 import org.openstreetmap.josm.tools.Utils;
     38import org.openstreetmap.josm.tools.XmlUtils;
    4039import org.xml.sax.SAXException;
    4140
     
    9796    public static void validateXML(Reader in) throws IOException, SAXException {
    9897        try (CachedFile cf = new CachedFile("resource://data/preferences.xsd"); InputStream xsdStream = cf.getInputStream()) {
    99             Schema schema = Utils.newXmlSchemaFactory().newSchema(new StreamSource(xsdStream));
     98            Schema schema = XmlUtils.newXmlSchemaFactory().newSchema(new StreamSource(xsdStream));
    10099            Validator validator = schema.newValidator();
    101100            validator.validate(new StreamSource(in));
     
    127126    public void parse() throws XMLStreamException, IOException {
    128127        if (reader != null) {
    129             this.parser = XMLInputFactory.newInstance().createXMLStreamReader(reader);
     128            this.parser = XmlUtils.newSafeXMLInputFactory().createXMLStreamReader(reader);
    130129            doParse();
    131130        } else {
    132131            try (BufferedReader in = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
    133                 this.parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
     132                this.parser = XmlUtils.newSafeXMLInputFactory().createXMLStreamReader(in);
    134133                doParse();
    135134            }
Note: See TracChangeset for help on using the changeset viewer.