]> granicus.if.org Git - postgis/commitdiff
Fix #2092 for trunk branch
authorOlivier Courtin <olivier.courtin@camptocamp.com>
Thu, 29 Nov 2012 22:33:21 +0000 (22:33 +0000)
committerOlivier Courtin <olivier.courtin@camptocamp.com>
Thu, 29 Nov 2012 22:33:21 +0000 (22:33 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10767 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_in_gml.c
postgis/lwgeom_in_kml.c
regress/in_kml.sql

index 2ad9b61ffb4333be440649e88f211514baa7b7c7..c811ad04d01c03a4ee21b2d96edfdf76c174ef56 100644 (file)
@@ -1798,7 +1798,7 @@ static LWGEOM* lwgeom_from_gml(const char* xml)
 
        /* Begin to Parse XML doc */
        xmlInitParser();
-       xmldoc = xmlParseMemory(xml, xml_size);
+        xmldoc = xmlReadMemory(xml, xml_size, NULL, NULL, XML_PARSE_SAX1);
        if (!xmldoc || (xmlroot = xmlDocGetRootElement(xmldoc)) == NULL)
        {
                xmlFreeDoc(xmldoc);
@@ -1806,7 +1806,6 @@ static LWGEOM* lwgeom_from_gml(const char* xml)
                gml_lwerror("invalid GML representation", 1);
        }
 
-
        lwgeom = parse_gml(xmlroot, &hasz, &root_srid);
 
        xmlFreeDoc(xmldoc);
index bfedeb737837f51ea3ac1a9cb79ba9033c3005c7..e2b3fbd40966ac7ed0954ef07d574bbec5312f20 100644 (file)
@@ -77,7 +77,7 @@ Datum geom_from_kml(PG_FUNCTION_ARGS)
 
        /* Begin to Parse XML doc */
        xmlInitParser();
-       xmldoc = xmlParseMemory(xml, xml_size);
+        xmldoc = xmldoc = xmlReadMemory(xml, xml_size, NULL, NULL, XML_PARSE_SAX1);
        if (!xmldoc || (xmlroot = xmlDocGetRootElement(xmldoc)) == NULL)
        {
                xmlFreeDoc(xmldoc);
@@ -136,23 +136,26 @@ static bool is_kml_namespace(xmlNodePtr xnode, bool is_strict)
         */
        if (ns == NULL) return !is_strict;
 
-       for (p=ns ; *p ; p++)
-       {
-               if ((*p)->href == NULL) continue;
-               if (!strcmp((char *) (*p)->href, KML_NS))
-               {
-                       if (    (*p)->prefix == NULL ||
-                               !xmlStrcmp(xnode->ns->prefix, (*p)->prefix))
-                       {
-
-                               xmlFree(ns);
-                               return true;
-                       }
-               }
-       }
-
-       xmlFree(ns);
-       return false;
+        for (p=ns ; *p ; p++)
+        {
+                if ((*p)->href == NULL || (*p)->prefix == NULL ||
+                     xnode->ns == NULL || xnode->ns->prefix == NULL) continue;
+
+                if (!xmlStrcmp(xnode->ns->prefix, (*p)->prefix))
+                {
+                        if (!strcmp((char *) (*p)->href, KML_NS))
+                        {
+                                xmlFree(ns);
+                                return true;
+                        } else {
+                                xmlFree(ns);
+                                return false;
+                        }
+                }
+        }
+
+        xmlFree(ns);
+        return !is_strict; /* Same reason here to not return false */;
 }
 
 
index c660a3c626a50123f3f608a81484403372f2c6c5..599808a2d2e42ef65c32ddcfe3dde47c59a15a79 100644 (file)
@@ -159,7 +159,7 @@ SELECT 'ns_1', ST_AsEWKT(ST_GeomFromKML('<kml:Point xmlns:kml="http://www.opengi
 SELECT 'ns_2', ST_AsEWKT(ST_GeomFromKML('<kml:Point xmlns="http://www.opengis.net/kml/2.2"><kml:coordinates>1,2</kml:coordinates></kml:Point>'));
 
 -- ERROR wrong namespace
-SELECT 'ns_3', ST_AsEWKT(ST_GeomFromKML('<kml:Point xmlns:gml="http://foo.net"><kml:coordinates>1,2</kml:coordinates></kml:Point>'));
+SELECT 'ns_3', ST_AsEWKT(ST_GeomFromKML('<kml:Point xmlns:kml="http://foo.net"><kml:coordinates>1,2</kml:coordinates></kml:Point>'));
 
 -- Several namespaces
 SELECT 'ns_4', ST_AsEWKT(ST_GeomFromKML('<kml:Point xmlns:foo="http://bar.net" xmlns:kml="http://www.opengis.net/kml/2.2"><kml:coordinates>1,2</kml:coordinates></kml:Point>'));