Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
aports
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alpine
aports
Merge requests
!75781
main/libxml2: upgrade to 2.13.5
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
main/libxml2: upgrade to 2.13.5
J0WI/aports:libxml2-2.13.5
into
master
Overview
4
Commits
1
Pipelines
1
Changes
2
1 unresolved thread
Hide all comments
Closed
J0WI
requested to merge
J0WI/aports:libxml2-2.13.5
into
master
3 months ago
Overview
4
Commits
1
Pipelines
1
Changes
2
1 unresolved thread
Hide all comments
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
d8fec6b0
1 commit,
3 months ago
2 files
+
4
−
121
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
main/libxml2/0001-parser-Fix-downstream-code-that-swaps-DTDs.patch deleted
100644 → 0
+
0
−
114
Options
From 551e925cf11d56269b0a1c8e6f58cc855d8b4757 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Wed, 30 Oct 2024 14:02:36 +0100
Subject: [PATCH] parser: Fix downstream code that swaps DTDs
Downstream code like the nginx xslt module can change the document's DTD
pointers in a SAX callback. If an entity from a separate DTD is parsed
lazily, its content must not reference the current document.
Regressed with commit d025cfbb.
Fixes #815.
(cherry picked from commit efb57ddba3571928395644568444990e8ea831ea)
---
parser.c | 9 +++++++++
testparser.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/parser.c b/parser.c
index 365025c5..82982a7a 100644
--- a/parser.c
+++ b/parser.c
@@ -12143,6 +12143,15 @@
xmlCtxtParseEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {
while (list != NULL) {
list->parent = (xmlNodePtr) ent;
+
+ /*
+ * Downstream code like the nginx xslt module can set
+ * ctxt->myDoc->extSubset to a separate DTD, so the entity
+ * might have a different or a NULL document.
+ */
+ if (list->doc != ent->doc)
+ xmlSetTreeDoc(list, ent->doc);
+
if (list->next == NULL)
ent->last = list;
list = list->next;
diff --git a/testparser.c b/testparser.c
index 1f8e58c4..342f6250 100644
--- a/testparser.c
+++ b/testparser.c
@@ -125,6 +125,57 @@
testCFileIO(void) {
return err;
}
+#ifdef LIBXML_VALID_ENABLED
+static void
+testSwitchDtdExtSubset(void *vctxt, const xmlChar *name ATTRIBUTE_UNUSED,
+ const xmlChar *externalId ATTRIBUTE_UNUSED,
+ const xmlChar *systemId ATTRIBUTE_UNUSED) {
+ xmlParserCtxtPtr ctxt = vctxt;
+
+ ctxt->myDoc->extSubset = ctxt->_private;
+}
+
+static int
+testSwitchDtd(void) {
+ const char dtdContent[] =
+ "<!ENTITY test '<elem1/><elem2/>'>\n";
+ const char docContent[] =
+ "<!DOCTYPE doc SYSTEM 'entities.dtd'>\n"
+ "<doc>&test;</doc>\n";
+ xmlParserInputBufferPtr input;
+ xmlParserCtxtPtr ctxt;
+ xmlDtdPtr dtd;
+ xmlDocPtr doc;
+ xmlEntityPtr ent;
+ int err = 0;
+
+ input = xmlParserInputBufferCreateStatic(dtdContent,
+ sizeof(dtdContent) - 1,
+ XML_CHAR_ENCODING_NONE);
+ dtd = xmlIOParseDTD(NULL, input, XML_CHAR_ENCODING_NONE);
+
+ ctxt = xmlNewParserCtxt();
+ ctxt->_private = dtd;
+ ctxt->sax->externalSubset = testSwitchDtdExtSubset;
+ doc = xmlCtxtReadMemory(ctxt, docContent, sizeof(docContent) - 1, NULL,
+ NULL, XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
+ xmlFreeParserCtxt(ctxt);
+
+ ent = xmlGetDocEntity(doc, BAD_CAST "test");
+ if (ent->children->doc != NULL) {
+ fprintf(stderr, "Entity content should have NULL doc\n");
+ err = 1;
+ }
+
+ /* Free doc before DTD */
+ doc->extSubset = NULL;
+ xmlFreeDoc(doc);
+ xmlFreeDtd(dtd);
+
+ return err;
+}
+#endif /* LIBXML_VALID_ENABLED */
+
#ifdef LIBXML_SAX1_ENABLED
static int
testBalancedChunk(void) {
@@ -571,6 +622,9 @@
main(void) {
err |= testUnsupportedEncoding();
err |= testNodeGetContent();
err |= testCFileIO();
+#ifdef LIBXML_VALID_ENABLED
+ err |= testSwitchDtd();
+#endif
#ifdef LIBXML_SAX1_ENABLED
err |= testBalancedChunk();
#endif
--
2.46.2
Loading