Skip to content

Commit

Permalink
Resolve external subset information for validity checking
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Jan 17, 2025
1 parent 3f7647f commit 102b290
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Source/Additions/GSXML.m
Original file line number Diff line number Diff line change
Expand Up @@ -2702,6 +2702,8 @@ + (void) initialize
const unsigned char *eid,
void *ctx)
{
xmlParserCtxtPtr cp = (xmlParserCtxtPtr)ctx;
BOOL restricted = NO;
NSString *file = nil;
NSString *entityId;
NSString *location;
Expand All @@ -2718,7 +2720,19 @@ + (void) initialize
parser = [HANDLER parser];
if (NO == [parser _resolves])
{
return xmlNewStringInputStream(ctx, (const xmlChar *)"");
if (cp->inSubset && cp->validate)
{
/* Resolving of external entities is turned off, but we are
* doing validity checking and are loading a subset, so we
* will need that subset to perform the validity checks.
* Proceed to do loading.
*/
restricted = YES;
}
else
{
return xmlNewStringInputStream(ctx, (const xmlChar *)"");
}
}

entityId = (eid != NULL) ? (id)UTF8Str(eid) : nil;
Expand Down Expand Up @@ -2901,10 +2915,15 @@ + (void) initialize
if ([file length] > 0)
{
NSURL *theURL = [NSURL fileURLWithPath: file];

xmlCatalogAdd((const unsigned char*)"public", eid,
UTF8STRING([theURL absoluteString]));
}

else if (restricted)
{
return xmlNewStringInputStream(ctx, (const xmlChar *)"");
}

/* A local DTD will now be in the catalog: The builtin entity resolver can
* take over.
*/
Expand All @@ -2915,7 +2934,7 @@ + (void) initialize
resolveEntityFunction(void *ctx,
const unsigned char *eid, const unsigned char *url)
{
NSLog(@"resolveEntityFunction called for %s %s", url, eid);
//NSLog(@"resolveEntityFunction called for %s %s", url, eid);
return loadEntityFunction(url, eid, ctx);
}

Expand Down

0 comments on commit 102b290

Please sign in to comment.