【发布时间】:2014-12-26 07:32:33
【问题描述】:
我看到了许多使用 XMLInputFactory、SAXParser 和 DocumentBuilderFactory 的解决方案。我们的项目是spring web service,我们唯一要做的就是:
@Bean
public Jaxb2Marshaller unmarshaller() {
Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller();
unmarshaller.setContextPath("foo");
unmarshaller.setProcessExternalEntities(false);
return unmarshaller;
}
然后我们将这个编组器和解组器传递给 MarshallingPayloadMethodProcessor。所以我的问题是 Jaxb2Marshaller 是否有一些属性可以阻止 DTD。比如:unmarshaller.setProperty(foo.SUPPORT_DTD, false);
我们有 .xsd 架构,但在 xml bomb 的情况下,需要扩展实体以进行验证,所以这似乎不是解决方案。
【问题讨论】: