From: Olivier Courtin Date: Thu, 29 Nov 2012 22:33:21 +0000 (+0000) Subject: Fix #2092 for trunk branch X-Git-Tag: 2.1.0beta2~342 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b18a62c05cc78973096f224f9c34447b70f9cab;p=postgis Fix #2092 for trunk branch git-svn-id: http://svn.osgeo.org/postgis/trunk@10767 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_in_gml.c b/postgis/lwgeom_in_gml.c index 2ad9b61ff..c811ad04d 100644 --- a/postgis/lwgeom_in_gml.c +++ b/postgis/lwgeom_in_gml.c @@ -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); diff --git a/postgis/lwgeom_in_kml.c b/postgis/lwgeom_in_kml.c index bfedeb737..e2b3fbd40 100644 --- a/postgis/lwgeom_in_kml.c +++ b/postgis/lwgeom_in_kml.c @@ -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 */; } diff --git a/regress/in_kml.sql b/regress/in_kml.sql index c660a3c62..599808a2d 100644 --- a/regress/in_kml.sql +++ b/regress/in_kml.sql @@ -159,7 +159,7 @@ SELECT 'ns_1', ST_AsEWKT(ST_GeomFromKML('1,2')); -- ERROR wrong namespace -SELECT 'ns_3', ST_AsEWKT(ST_GeomFromKML('1,2')); +SELECT 'ns_3', ST_AsEWKT(ST_GeomFromKML('1,2')); -- Several namespaces SELECT 'ns_4', ST_AsEWKT(ST_GeomFromKML('1,2'));