根据您的示例,您可以尝试以下代码:
public static <T> T unMarshal(org.w3c.dom.Element content, Class<T> clazz) throws JAXBException, XMLStreamException {
JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
XMLInputFactory xmlif = XMLInputFactory.newFactory();
xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
xmlif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
XMLStreamReader xsr = xmlif.createXMLStreamReader(content);
return (T) unmarshaller.unmarshal(xsr, clazz).getValue();
}
我认为上述解决方案可以解决与(CWE 611)XML外部实体引用相关的问题