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


##########
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:
   Good catch, dropped both external-entity lines. `disallow-doctype-decl` 
throws on the DOCTYPE so nothing reaches the entity-resolution path anyway. 
Test still rejects the payload.



-- 
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