1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
https://repo.or.cz/siplcs.git/commit/8c37bad762decd3aad86cfe758187a610804b196
Bug: https://bugs.gentoo.org/932640
From: Stefan Becker <chemobejk@gmail.com>
Date: Mon, 22 Jan 2024 22:47:20 +0200
Subject: [PATCH] xml: update for libxml2 >= 2.12 API changes
- error callback is now passed a const error
- provide alternative implementation for the deprecated
xmlSAXUserParseMemory() API
--- 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);
--
2.11.4.GIT
|