Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure XML parsers used for p2 metadata to eliminate entity limits #581

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.repository;singleton:=true
Bundle-Version: 2.9.200.qualifier
Bundle-Version: 2.9.300.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.repository.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@

public abstract class XMLParser extends DefaultHandler implements XMLConstants {

// Java 24 and onward restricts the number of entities that may appear in an XML
// document. This limit in too restrictive for p2 XML metadata where a large
// update site can easily have 500,000 or more entities.
//
// https://docs.oracle.com/en/java/javase/17/docs/api/java.xml/module-summary.html#IN_ISFPtable
private static final int MAX_ENTITIES = 0;

// Get the root object that is being parsed.
protected abstract Object getRootObject();

Expand Down Expand Up @@ -88,6 +95,18 @@ protected SAXParser getParser() throws ParserConfigurationException, SAXExceptio
if (theParser == null) {
throw new SAXException(Messages.XMLParser_No_SAX_Parser);
}
try {
theParser.setProperty("jdk.xml.totalEntitySizeLimit", //$NON-NLS-1$
Integer.getInteger("jdk.xml.totalEntitySizeLimit", MAX_ENTITIES)); //$NON-NLS-1$
} catch (SAXException se) {
// Maybe not supported.
}
try {
theParser.setProperty("jdk.xml.maxGeneralEntitySizeLimit", //$NON-NLS-1$
Integer.getInteger("jdk.xml.maxGeneralEntitySizeLimit", MAX_ENTITIES)); //$NON-NLS-1$
} catch (SAXException se) {
// Maybe not supported.
}
xmlReader = theParser.getXMLReader();
return theParser;
}
Expand Down
Loading