Ignore:
Timestamp:
2015-04-28T01:11:18+02:00 (9 years ago)
Author:
Don-vip
Message:

fix findsecbugs:XXE_SAXPARSER - "Security - XML Parsing Vulnerable to XXE (SAXParser)"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7894 r8287  
    5050import java.util.zip.ZipInputStream;
    5151
     52import javax.xml.XMLConstants;
     53import javax.xml.parsers.ParserConfigurationException;
     54import javax.xml.parsers.SAXParser;
     55import javax.xml.parsers.SAXParserFactory;
     56
    5257import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
    5358import org.openstreetmap.josm.Main;
    5459import org.openstreetmap.josm.data.Version;
     60import org.xml.sax.SAXException;
    5561
    5662/**
     
    11641170        return null;
    11651171    }
     1172
     1173    /**
     1174     * Returns a new secure SAX parser, supporting XML namespaces.
     1175     * @return a new secure SAX parser, supporting XML namespaces
     1176     * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
     1177     * @throws SAXException for SAX errors.
     1178     * @since 8287
     1179     */
     1180    public static SAXParser newSafeSAXParser() throws ParserConfigurationException, SAXException {
     1181        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
     1182        parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
     1183        parserFactory.setNamespaceAware(true);
     1184        return parserFactory.newSAXParser();
     1185    }
    11661186}
Note: See TracChangeset for help on using the changeset viewer.