Changeset 14441 in josm
- Timestamp:
- 2018-11-22T00:34:59+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/preferences/PreferencesReader.java
r13901 r14441 26 26 import javax.xml.transform.stream.StreamSource; 27 27 import javax.xml.validation.Schema; 28 import javax.xml.validation.Validator;29 28 30 29 import org.openstreetmap.josm.io.CachedFile; … … 97 96 try (CachedFile cf = new CachedFile("resource://data/preferences.xsd"); InputStream xsdStream = cf.getInputStream()) { 98 97 Schema schema = XmlUtils.newXmlSchemaFactory().newSchema(new StreamSource(xsdStream)); 99 Validator validator = schema.newValidator(); 100 validator.validate(new StreamSource(in)); 98 XmlUtils.newSafeValidator(schema).validate(new StreamSource(in)); 101 99 } 102 100 } -
trunk/src/org/openstreetmap/josm/tools/OptionParser.java
r14435 r14441 64 64 public OptionParser addFlagParameter(String optionName, Runnable handler) { 65 65 checkOptionName(optionName); 66 availableOptions.put("--" + optionName, new AvailableOption() { 67 @Override 68 public void runFor(String parameter) { 69 handler.run(); 70 } 71 }); 66 availableOptions.put("--" + optionName, parameter -> handler.run()); 72 67 return this; 73 68 } -
trunk/src/org/openstreetmap/josm/tools/XmlUtils.java
r14348 r14441 14 14 import javax.xml.transform.TransformerConfigurationException; 15 15 import javax.xml.transform.TransformerFactory; 16 import javax.xml.validation.Schema; 16 17 import javax.xml.validation.SchemaFactory; 17 18 import javax.xml.validation.SchemaFactoryConfigurationError; 19 import javax.xml.validation.Validator; 18 20 19 21 import org.w3c.dom.Document; … … 23 25 import org.xml.sax.InputSource; 24 26 import org.xml.sax.SAXException; 27 import org.xml.sax.SAXNotRecognizedException; 28 import org.xml.sax.SAXNotSupportedException; 25 29 import org.xml.sax.helpers.DefaultHandler; 26 30 … … 146 150 147 151 /** 152 * Returns a new secure {@link Validator}. 153 * @param schema XML schema 154 * @return a new secure {@link Validator} 155 * @since 14441 156 */ 157 public static Validator newSafeValidator(Schema schema) { 158 Validator validator = schema.newValidator(); 159 try { 160 validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); 161 validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); 162 } catch (SAXNotRecognizedException | SAXNotSupportedException e) { 163 // All implementations that implement JAXP 1.5 or newer are required to support these two properties 164 Logging.trace(e); 165 } 166 return validator; 167 } 168 169 /** 148 170 * Get the first child element 149 171 * @param parent parent node
Note:
See TracChangeset
for help on using the changeset viewer.