X-Git-Url: https://repo.or.cz/siplcs.git/blobdiff_plain/3db51111de53d85b53a07825ff8b22e1ae4d1840..8c37bad762decd3aad86cfe758187a610804b196:/src/core/sipe-xml.c diff --git a/src/core/sipe-xml.c b/src/core/sipe-xml.c index cfc53115..e69d6d02 100644 --- a/src/core/sipe-xml.c +++ b/src/core/sipe-xml.c @@ -154,7 +154,13 @@ static void callback_error(void *user_data, const char *msg, ...) g_free(errmsg); } -static void callback_serror(void *user_data, xmlErrorPtr error) +static void callback_serror(void *user_data, +#if LIBXML_VERSION > 21200 + const xmlError *error +#else + xmlErrorPtr error +#endif +) { struct _parser_data *pd = user_data; @@ -217,8 +223,31 @@ sipe_xml *sipe_xml_parse(const gchar *string, gsize length) if (string && length) { struct _parser_data *pd = g_new0(struct _parser_data, 1); +#if LIBXML_VERSION > 21200 + xmlParserCtxtPtr ctxt = xmlNewSAXParserCtxt(&parser, pd); + + if (ctxt) { + xmlCtxtReadMemory(ctxt, + string, + length, + NULL, + NULL, + 0); + + pd->error = !ctxt->wellFormed; + + if (ctxt->myDoc) { + xmlFreeDoc(ctxt->myDoc); + ctxt->myDoc = NULL; + } + + xmlFreeParserCtxt(ctxt); + } else + pd->error = TRUE; +#else if (xmlSAXUserParseMemory(&parser, pd, string, length)) pd->error = TRUE; +#endif if (pd->error) { sipe_xml_free(pd->root);