ppkarwasz commented on code in PR #5006:
URL: https://github.com/apache/calcite/pull/5006#discussion_r3382514602


##########
core/src/main/java/org/apache/calcite/runtime/SpatialTypeUtils.java:
##########
@@ -135,8 +140,19 @@ public static Geometry fromGeoJson(String geoJson) {
    */
   public static Geometry fromGml(String gml) {
     try {
-      GMLReader reader = new GMLReader();
-      return reader.read(gml, GEOMETRY_FACTORY);
+      // GMLReader.read builds its own SAXParserFactory with external entities
+      // enabled, so parse with a hardened reader and feed JTS's GMLHandler.
+      final SAXParserFactory factory = SAXParserFactory.newInstance();
+      factory.setNamespaceAware(true);
+      
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl";, 
true);
+      
factory.setFeature("http://xml.org/sax/features/external-general-entities";, 
false);
+      
factory.setFeature("http://xml.org/sax/features/external-parameter-entities";, 
false);

Review Comment:
   Setting all three features is overkill, since `disallow-doctype-decl` will 
throw on a `DOCTYPE` declaration and will therefore not parse any external 
subset (`non-validating/load-external-dtd`) nor entities.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to