Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fengjueding
spring-framework
提交
4196e6c9
S
spring-framework
项目概览
fengjueding
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4196e6c9
编写于
4月 28, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AbstractMarshaller avoids SAXSource workaround when processExternalEntities=true
Issue: SPR-11737 (cherry picked from commit
93d13cfc
)
上级
59cef3ce
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
47 deletion
+32
-47
spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
...in/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
+2
-4
spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java
...a/org/springframework/oxm/support/AbstractMarshaller.java
+20
-39
spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java
...va/org/springframework/oxm/xstream/XStreamMarshaller.java
+10
-4
未找到文件。
spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
浏览文件 @
4196e6c9
...
...
@@ -401,7 +401,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
*
@return
the configured value for whether XML external entities are allowed.
*
Returns
the configured value for whether XML external entities are allowed.
*/
public
boolean
isProcessExternalEntities
()
{
return
this
.
processExternalEntities
;
...
...
@@ -806,9 +806,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
if
(
xmlReader
==
null
)
{
xmlReader
=
XMLReaderFactory
.
createXMLReader
();
}
xmlReader
.
setFeature
(
"http://xml.org/sax/features/external-general-entities"
,
this
.
processExternalEntities
);
xmlReader
.
setFeature
(
"http://xml.org/sax/features/external-general-entities"
,
isProcessExternalEntities
());
return
new
SAXSource
(
xmlReader
,
inputSource
);
}
catch
(
SAXException
ex
)
{
...
...
spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java
浏览文件 @
4196e6c9
...
...
@@ -58,8 +58,8 @@ import org.springframework.util.xml.StaxUtils;
/**
* Abstract implementation of the {@code Marshaller} and {@code Unmarshaller} interface.
* This implementation inspects the given {@code Source} or {@code Result}, and
defers
* further handling to overridable template methods.
* This implementation inspects the given {@code Source} or {@code Result}, and
*
delegates
further handling to overridable template methods.
*
* @author Arjen Poutsma
* @author Juergen Hoeller
...
...
@@ -162,6 +162,7 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller {
/**
* Determine the default encoding to use for marshalling or unmarshalling from
* a byte stream, or {@code null} if none.
* <p>The default implementation returns {@code null}.
*/
protected
String
getDefaultEncoding
()
{
return
null
;
...
...
@@ -315,7 +316,7 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller {
return
unmarshalSaxSource
((
SAXSource
)
source
);
}
else
if
(
source
instanceof
StreamSource
)
{
return
unmarshalStreamSource
NoExternalEntitities
((
StreamSource
)
source
);
return
unmarshalStreamSource
((
StreamSource
)
source
);
}
else
{
throw
new
IllegalArgumentException
(
"Unknown Source type: "
+
source
.
getClass
());
...
...
@@ -388,41 +389,9 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller {
return
unmarshalSaxReader
(
saxSource
.
getXMLReader
(),
saxSource
.
getInputSource
());
}
/**
* Template method for handling {@code StreamSource}s with protection against
* the XML External Entity (XXE) processing vulnerability taking into account
* the value of the {@link #setProcessExternalEntities(boolean)} property.
* <p>The default implementation wraps the StreamSource as a SAXSource and delegates
* to {@link #unmarshalSaxSource(javax.xml.transform.sax.SAXSource)}.
* @param streamSource the {@code StreamSource}
* @return the object graph
* @throws IOException if an I/O exception occurs
* @throws XmlMappingException if the given source cannot be mapped to an object
* @see <a href="https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing">XML_External_Entity_(XXE)_Processing</a>
*/
protected
Object
unmarshalStreamSourceNoExternalEntitities
(
StreamSource
streamSource
)
throws
XmlMappingException
,
IOException
{
InputSource
inputSource
;
if
(
streamSource
.
getInputStream
()
!=
null
)
{
inputSource
=
new
InputSource
(
streamSource
.
getInputStream
());
inputSource
.
setEncoding
(
getDefaultEncoding
());
}
else
if
(
streamSource
.
getReader
()
!=
null
)
{
inputSource
=
new
InputSource
(
streamSource
.
getReader
());
}
else
{
inputSource
=
new
InputSource
(
streamSource
.
getSystemId
());
}
return
unmarshalSaxSource
(
new
SAXSource
(
inputSource
));
}
/**
* Template method for handling {@code StreamSource}s.
* <p>This implementation defers to {@code unmarshalInputStream} or {@code unmarshalReader}.
* <p>As of Spring 3.2.8, this method is no longer invoked from
* {@link #unmarshal(javax.xml.transform.Source)}. The method invoked instead is
* {@link #unmarshalStreamSourceNoExternalEntitities(javax.xml.transform.stream.StreamSource)}.
* <p>This implementation delegates to {@code unmarshalInputStream} or {@code unmarshalReader}.
* @param streamSource the {@code StreamSource}
* @return the object graph
* @throws IOException if an I/O exception occurs
...
...
@@ -430,13 +399,25 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller {
*/
protected
Object
unmarshalStreamSource
(
StreamSource
streamSource
)
throws
XmlMappingException
,
IOException
{
if
(
streamSource
.
getInputStream
()
!=
null
)
{
return
unmarshalInputStream
(
streamSource
.
getInputStream
());
if
(
isProcessExternalEntities
())
{
return
unmarshalInputStream
(
streamSource
.
getInputStream
());
}
else
{
InputSource
inputSource
=
new
InputSource
(
streamSource
.
getInputStream
());
inputSource
.
setEncoding
(
getDefaultEncoding
());
return
unmarshalSaxSource
(
new
SAXSource
(
inputSource
));
}
}
else
if
(
streamSource
.
getReader
()
!=
null
)
{
return
unmarshalReader
(
streamSource
.
getReader
());
if
(
isProcessExternalEntities
())
{
return
unmarshalReader
(
streamSource
.
getReader
());
}
else
{
return
unmarshalSaxSource
(
new
SAXSource
(
new
InputSource
(
streamSource
.
getReader
())));
}
}
else
{
throw
new
IllegalArgumentException
(
"StreamSource contains neither InputStream nor Reader"
);
return
unmarshalSaxSource
(
new
SAXSource
(
new
InputSource
(
streamSource
.
getSystemId
()))
);
}
}
...
...
spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java
浏览文件 @
4196e6c9
...
...
@@ -731,10 +731,16 @@ public class XStreamMarshaller extends AbstractMarshaller implements Initializin
// Unmarshalling
@Override
protected
Object
unmarshalStreamSourceNoExternalEntitities
(
StreamSource
streamSource
)
throws
XmlMappingException
,
IOException
{
return
super
.
unmarshalStreamSource
(
streamSource
);
protected
Object
unmarshalStreamSource
(
StreamSource
streamSource
)
throws
XmlMappingException
,
IOException
{
if
(
streamSource
.
getInputStream
()
!=
null
)
{
return
unmarshalInputStream
(
streamSource
.
getInputStream
());
}
else
if
(
streamSource
.
getReader
()
!=
null
)
{
return
unmarshalReader
(
streamSource
.
getReader
());
}
else
{
throw
new
IllegalArgumentException
(
"StreamSource contains neither InputStream nor Reader"
);
}
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录