1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-26 00:37:43 +03:00

parser: Fix base URI of internal parameter entities

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
This commit is contained in:
Nick Wellnhofer
2024-05-03 00:44:42 +02:00
parent fdc5ff3657
commit 71a7a33e18

9
SAX2.c
View File

@@ -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);