Skip to content

Commit 78d0958

Browse files
committedDec 6, 2023
8321406: Null IDs should be resolved as before catalogs are added
Reviewed-by: naoto, iris, lancea
1 parent aaaae3e commit 78d0958

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

‎src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,8 @@ public StaxXMLInputSource resolveEntityAsPerStax(XMLResourceIdentifier resourceI
10381038
}
10391039

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

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

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.