Skip to content

Commit 9c7f4a7

Browse files
Parse xml without downloading external entities
1 parent 10a1670 commit 9c7f4a7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgPackager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import javax.xml.stream.XMLStreamWriter;
4747
import javax.xml.transform.TransformerException;
4848
import javax.xml.transform.TransformerFactory;
49+
import javax.xml.transform.dom.DOMSource;
4950
import javax.xml.transform.stream.StreamResult;
5051
import javax.xml.transform.stream.StreamSource;
5152
import jdk.internal.util.Architecture;
@@ -59,6 +60,7 @@
5960
import jdk.jpackage.internal.model.PackagerException;
6061
import jdk.jpackage.internal.resources.ResourceLocator;
6162
import jdk.jpackage.internal.util.XmlUtils;
63+
import org.xml.sax.SAXException;
6264

6365
record MacPkgPackager(MacPkgPackage pkg, BuildEnv env, Optional<Services> services, Path outputDir) {
6466

@@ -463,11 +465,12 @@ private void prepareConfigFiles() throws IOException {
463465

464466
private void patchCPLFile(Path cpl) throws IOException {
465467
try (final var xsltResource = ResourceLocator.class.getResourceAsStream("adjust-component-plist.xsl")) {
466-
final var srcXml = new StreamSource(new ByteArrayInputStream(Files.readAllBytes(cpl)));
468+
final var srcXml = new DOMSource(XmlUtils.initDocumentBuilder().parse(
469+
new ByteArrayInputStream(Files.readAllBytes(cpl))));
467470
final var dstXml = new StreamResult(cpl.toFile());
468471
final var xslt = TransformerFactory.newInstance().newTransformer(new StreamSource(xsltResource));
469472
xslt.transform(srcXml, dstXml);
470-
} catch (TransformerException ex) {
473+
} catch (TransformerException|SAXException ex) {
471474
throw new RuntimeException(ex);
472475
}
473476
}

0 commit comments

Comments
 (0)