aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2024-05-03 00:44:42 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2024-05-03 11:53:45 +0200
commit71a7a33e18fce3822405be2c4ce40d03064d48ea (patch)
tree5d2f89bf79bbd1636f7ccdc933637687509cef84
parentfdc5ff36571ec7b19b991d5ed4126369095c1cb8 (diff)
downloadlibxml2-upstream-master.tar.gz
parser: Fix base URI of internal parameter entitiesupstream-master
Search parent inputs of internal parameter entities for base URI. Fixes a long-standing bug, which manifested in a different way after commit 955c177f. Reproduce with xmllint --noent xmlconf/eduni/errata-2e/E18.xml
-rw-r--r--SAX2.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/SAX2.c b/SAX2.c
index a347023b..b8011fec 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -559,9 +559,14 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
if ((ent->URI == NULL) && (systemId != NULL)) {
xmlChar *URI;
const char *base = NULL;
+ int i;
- if (ctxt->input != NULL)
- base = ctxt->input->filename;
+ for (i = ctxt->inputNr - 1; i >= 0; i--) {
+ if (ctxt->inputTab[i]->filename != NULL) {
+ base = ctxt->inputTab[i]->filename;
+ break;
+ }
+ }
if (xmlBuildURISafe(systemId, (const xmlChar *) base, &URI) < 0) {
xmlSAX2ErrMemory(ctxt);