1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

SAX2: Reenable 'directory' as base URI fallback

Apparently, some users overwrite this member manually to set a base URI
for memory streams.

Fixes #753.
This commit is contained in:
Nick Wellnhofer 2024-07-03 11:55:38 +02:00
parent 842a044831
commit 80aabea1d6

14
SAX2.c
View File

@ -408,6 +408,13 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId,
if (ctxt->input != NULL)
base = BAD_CAST ctxt->input->filename;
/*
* We don't really need the 'directory' struct member, but some
* users set it manually to a base URI for memory streams.
*/
if (base == NULL)
base = BAD_CAST ctxt->directory;
if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
(xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
@ -570,6 +577,13 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
}
}
/*
* We don't really need the 'directory' struct member, but some
* users set it manually to a base URI for memory streams.
*/
if (base == NULL)
base = ctxt->directory;
res = xmlBuildURISafe(systemId, (const xmlChar *) base, &URI);
if (URI == NULL) {