dev #13

Merged
JoeKung merged 23 commits from dev into main 2026-03-03 18:28:30 +01:00
Showing only changes of commit e23bca0734 - Show all commits

View File

@@ -639,9 +639,17 @@ public class SlicerService {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true); dbf.setNamespaceAware(true);
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
setFeatureIfSupported(dbf, "http://apache.org/xml/features/disallow-doctype-decl", true); dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
setFeatureIfSupported(dbf, "http://xml.org/sax/features/external-general-entities", false); try {
setFeatureIfSupported(dbf, "http://xml.org/sax/features/external-parameter-entities", false); dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
} catch (Exception ignored) {
// Best-effort hardening.
}
try {
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
} catch (Exception ignored) {
// Best-effort hardening.
}
dbf.setXIncludeAware(false); dbf.setXIncludeAware(false);
dbf.setExpandEntityReferences(false); dbf.setExpandEntityReferences(false);
@@ -650,14 +658,6 @@ public class SlicerService {
} }
} }
private void setFeatureIfSupported(DocumentBuilderFactory dbf, String feature, boolean enabled) {
try {
dbf.setFeature(feature, enabled);
} catch (Exception ignored) {
// Best-effort hardening.
}
}
private String normalizeZipPath(String rawPath) throws IOException { private String normalizeZipPath(String rawPath) throws IOException {
if (rawPath == null || rawPath.isBlank()) { if (rawPath == null || rawPath.isBlank()) {
throw new IOException("Invalid empty 3MF model path"); throw new IOException("Invalid empty 3MF model path");