Skip to content

Commit

Permalink
8321406: Null IDs should be resolved as before catalogs are added
Browse files Browse the repository at this point in the history
Reviewed-by: naoto, iris, lancea
  • Loading branch information
JoeWang-Java committed Dec 6, 2023
1 parent aaaae3e commit 78d0958
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,8 @@ public StaxXMLInputSource resolveEntityAsPerStax(XMLResourceIdentifier resourceI
}

// Step 2: custom catalog if specified
if (staxInputSource == null && (fUseCatalog && fCatalogFile != null)) {
if ((publicId != null || literalSystemId != null) &&
staxInputSource == null && (fUseCatalog && fCatalogFile != null)) {
if (fCatalogResolver == null) {
fCatalogFeatures = JdkXmlUtils.getCatalogFeatures(fDefer, fCatalogFile, fPrefer, fResolve);
fCatalogResolver = CatalogManager.catalogResolver(fCatalogFeatures);
Expand All @@ -1048,18 +1049,21 @@ public StaxXMLInputSource resolveEntityAsPerStax(XMLResourceIdentifier resourceI
}

// Step 3: use the default JDK Catalog Resolver if Step 2's resolve is continue
if (staxInputSource == null && JdkXmlUtils.isResolveContinue(fCatalogFeatures)) {
if ((publicId != null || literalSystemId != null) &&
staxInputSource == null && JdkXmlUtils.isResolveContinue(fCatalogFeatures)) {
initJdkCatalogResolver();

staxInputSource = resolveWithCatalogStAX(fDefCR, JdkCatalog.JDKCATALOG, publicId, literalSystemId);
}

// Step 4: default resolution if not resolved by a resolver and the RESOLVE
// feature is set to 'continue'
// Note if both publicId and systemId are null, the resolution process continues as usual
if (staxInputSource != null) {
fISCreatedByResolver = true;
} else if (JdkXmlUtils.isResolveContinue(fCatalogFeatures) &&
fSecurityManager.is(Limit.JDKCATALOG_RESOLVE, JdkConstants.CONTINUE)) {
} else if ((publicId == null && literalSystemId == null) ||
(JdkXmlUtils.isResolveContinue(fCatalogFeatures) &&
fSecurityManager.is(Limit.JDKCATALOG_RESOLVE, JdkConstants.CONTINUE))) {
staxInputSource = new StaxXMLInputSource(
new XMLInputSource(publicId, literalSystemId, baseSystemId, true), false);
}
Expand Down Expand Up @@ -1222,8 +1226,10 @@ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) th

// Step 4: default resolution if not resolved by a resolver and the RESOLVE
// feature is set to 'continue'
if ((xmlInputSource == null) && JdkXmlUtils.isResolveContinue(fCatalogFeatures) &&
fSecurityManager.is(Limit.JDKCATALOG_RESOLVE, JdkConstants.CONTINUE)) {
// Note if both publicId and systemId are null, the resolution process continues as usual
if ((publicId == null && literalSystemId == null) ||
((xmlInputSource == null) && JdkXmlUtils.isResolveContinue(fCatalogFeatures) &&
fSecurityManager.is(Limit.JDKCATALOG_RESOLVE, JdkConstants.CONTINUE))) {
xmlInputSource = new XMLInputSource(publicId, literalSystemId, baseSystemId, false);
}

Expand Down

1 comment on commit 78d0958

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.