Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 4a0d74d

Browse files
committed
SAX2: Reenable 'directory' as base URI fallback
Apparently, some users overwrite this member manually to set a base URI for memory streams. Fixes #753.
1 parent 2f6766d commit 4a0d74d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

SAX2.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId
412412
if (ctxt->input != NULL)
413413
base = BAD_CAST ctxt->input->filename;
414414

415+
/*
416+
* We don't really need the 'directory' struct member, but some
417+
* users set it manually to a base URI for memory streams.
418+
*/
419+
if (base == NULL)
420+
base = BAD_CAST ctxt->directory;
421+
415422
if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
416423
(xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
417424
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
@@ -574,6 +581,13 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
574581
}
575582
}
576583

584+
/*
585+
* We don't really need the 'directory' struct member, but some
586+
* users set it manually to a base URI for memory streams.
587+
*/
588+
if (base == NULL)
589+
base = ctxt->directory;
590+
577591
res = xmlBuildURISafe(systemId, (const xmlChar *) base, &URI);
578592

579593
if (URI == NULL) {

0 commit comments

Comments
 (0)