|
| 1 | +rom f75abfcaa419a740a3191e56c60400f3ff18988d Mon Sep 17 00:00:00 2001 |
| 2 | +From: Daniel Garcia Moreno <daniel.garcia@suse.com> |
| 3 | +Date: Fri, 19 Dec 2025 11:02:18 +0100 |
| 4 | +Subject: [PATCH] catalog: Ignore repeated nextCatalog entries |
| 5 | + |
| 6 | +This patch makes the catalog parsing to ignore repeated entries of |
| 7 | +nextCatalog with the same value. |
| 8 | + |
| 9 | +Fix https://gitlab.gnome.org/GNOME/libxml2/-/issues/1019 |
| 10 | + |
| 11 | +Upstream Patch reference: https://gitlab.gnome.org/GNOME/libxml2/-/commit/f75abfcaa419a740a3191e56c60400f3ff18988d.patch |
| 12 | +--- |
| 13 | + catalog.c | 26 ++++++++++++++++++++++++++ |
| 14 | + error.c | 11 +++++++++++ |
| 15 | + 2 files changed, 37 insertions(+) |
| 16 | + |
| 17 | +diff --git a/catalog.c b/catalog.c |
| 18 | +index 20e9576..3886d84 100644 |
| 19 | +--- a/catalog.c |
| 20 | ++++ b/catalog.c |
| 21 | +@@ -242,6 +242,14 @@ xmlCatalogErr(xmlCatalogEntryPtr catal, xmlNodePtr node, int error, |
| 22 | + msg, str1, str2, str3); |
| 23 | + } |
| 24 | + |
| 25 | ++static void |
| 26 | ++xmlCatalogPrintDebug(const char *fmt, ...) { |
| 27 | ++ va_list ap; |
| 28 | ++ |
| 29 | ++ va_start(ap, fmt); |
| 30 | ++ xmlVPrintErrorMessage(fmt, ap); |
| 31 | ++ va_end(ap); |
| 32 | ++} |
| 33 | + |
| 34 | + /************************************************************************ |
| 35 | + * * |
| 36 | +@@ -1267,9 +1275,27 @@ xmlParseXMLCatalogNode(xmlNodePtr cur, xmlCatalogPrefer prefer, |
| 37 | + BAD_CAST "delegateURI", BAD_CAST "uriStartString", |
| 38 | + BAD_CAST "catalog", prefer, cgroup); |
| 39 | + } else if (xmlStrEqual(cur->name, BAD_CAST "nextCatalog")) { |
| 40 | ++ xmlCatalogEntryPtr prev = parent->children; |
| 41 | ++ |
| 42 | + entry = xmlParseXMLCatalogOneNode(cur, XML_CATA_NEXT_CATALOG, |
| 43 | + BAD_CAST "nextCatalog", NULL, |
| 44 | + BAD_CAST "catalog", prefer, cgroup); |
| 45 | ++ /* Avoid duplication of nextCatalog */ |
| 46 | ++ while (prev != NULL) { |
| 47 | ++ if ((prev->type == XML_CATA_NEXT_CATALOG) && |
| 48 | ++ (xmlStrEqual (prev->URL, entry->URL)) && |
| 49 | ++ (xmlStrEqual (prev->value, entry->value)) && |
| 50 | ++ (prev->prefer == entry->prefer) && |
| 51 | ++ (prev->group == entry->group)) { |
| 52 | ++ if (xmlDebugCatalogs) |
| 53 | ++ xmlCatalogPrintDebug( |
| 54 | ++ "Ignoring repeated nextCatalog %s\n", entry->URL); |
| 55 | ++ xmlFreeCatalogEntry(entry, NULL); |
| 56 | ++ entry = NULL; |
| 57 | ++ break; |
| 58 | ++ } |
| 59 | ++ prev = prev->next; |
| 60 | ++ } |
| 61 | + } |
| 62 | + if (entry != NULL) { |
| 63 | + if (parent != NULL) { |
| 64 | +diff --git a/error.c b/error.c |
| 65 | +index 4de1418..a77e2da 100644 |
| 66 | +--- a/error.c |
| 67 | ++++ b/error.c |
| 68 | +@@ -1022,3 +1022,14 @@ xmlCopyError(xmlErrorPtr from, xmlErrorPtr to) { |
| 69 | + return 0; |
| 70 | + } |
| 71 | + |
| 72 | ++/** |
| 73 | ++ * Prints to stderr. |
| 74 | ++ * |
| 75 | ++ * @param fmt printf-like format string |
| 76 | ++ * @param ap arguments |
| 77 | ++ */ |
| 78 | ++void |
| 79 | ++xmlVPrintErrorMessage(const char *fmt, va_list ap) { |
| 80 | ++ vfprintf(stderr, fmt, ap); |
| 81 | ++} |
| 82 | ++ |
| 83 | +-- |
| 84 | +2.43.0 |
| 85 | + |
0 commit comments