mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
【重要】删除XmlUtil.readObjectFromXml方法,避免漏洞
This commit is contained in:
parent
8a6fe9a2ab
commit
02e85a80e5
@ -3,10 +3,9 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.8.12.M1 (2023-01-19)
|
# 5.8.12.M1 (2023-02-09)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【core 】 XmlUtil.readObjectFromXml增加注入漏洞的警告注释,并标识为废弃(issue#2857@Github)
|
|
||||||
* 【http 】 HttpGlobalConfig.allowPatch()调用时忽略错误(issue#2832@Github)
|
* 【http 】 HttpGlobalConfig.allowPatch()调用时忽略错误(issue#2832@Github)
|
||||||
* 【core 】 重构根据file magic number判断文件类型(pr#2834@Github)
|
* 【core 】 重构根据file magic number判断文件类型(pr#2834@Github)
|
||||||
* 【core 】 增加WGS84 坐标与墨卡托投影互转(pr#2811@Github)
|
* 【core 】 增加WGS84 坐标与墨卡托投影互转(pr#2811@Github)
|
||||||
@ -22,6 +21,7 @@
|
|||||||
* 【core 】 修复FileUtil的rename在newName与原文件夹名称一样时,文件夹会被删除问题(issue#2845@Github)
|
* 【core 】 修复FileUtil的rename在newName与原文件夹名称一样时,文件夹会被删除问题(issue#2845@Github)
|
||||||
* 【core 】 修复IoUtil.readBytes使用SocketInputStream读取不完整问题(issue#I6AT49@Gitee)
|
* 【core 】 修复IoUtil.readBytes使用SocketInputStream读取不完整问题(issue#I6AT49@Gitee)
|
||||||
* 【core 】 修复ClassScanner自定义classload无效问题(issue#I68TV2@Gitee)
|
* 【core 】 修复ClassScanner自定义classload无效问题(issue#I68TV2@Gitee)
|
||||||
|
* 【core 】 【重要】删除XmlUtil.readObjectFromXml方法,避免漏洞(issue#2857@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ import javax.xml.xpath.XPath;
|
|||||||
import javax.xml.xpath.XPathConstants;
|
import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import java.beans.XMLDecoder;
|
|
||||||
import java.beans.XMLEncoder;
|
import java.beans.XMLEncoder;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -330,62 +329,6 @@ public class XmlUtil {
|
|||||||
return readXML(StrUtil.getReader(xmlStr));
|
return readXML(StrUtil.getReader(xmlStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 从XML中读取对象 Reads serialized object from the XML file.<br>
|
|
||||||
* 注意,使用此方法解析不受信任 XML 字符串时,可能容易受到远程代码执行攻击!<br>
|
|
||||||
* 见:https://gitee.com/dromara/hutool/issues/I6AEX2
|
|
||||||
*
|
|
||||||
* @param <T> 对象类型
|
|
||||||
* @param source XML文件
|
|
||||||
* @return 对象
|
|
||||||
* @deprecated 使用此方法解析不受信任 XML 字符串时,可能容易受到远程代码执行攻击,废弃
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static <T> T readObjectFromXml(File source) {
|
|
||||||
return readObjectFromXml(new InputSource(FileUtil.getInputStream(source)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从XML中读取对象 Reads serialized object from the XML file.<br>
|
|
||||||
* 注意,使用此方法解析不受信任 XML 字符串时,可能容易受到远程代码执行攻击!<br>
|
|
||||||
* 见:https://gitee.com/dromara/hutool/issues/I6AEX2
|
|
||||||
*
|
|
||||||
* @param <T> 对象类型
|
|
||||||
* @param xmlStr XML内容
|
|
||||||
* @return 对象
|
|
||||||
* @since 3.2.0
|
|
||||||
* @deprecated 使用此方法解析不受信任 XML 字符串时,可能容易受到远程代码执行攻击,废弃
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static <T> T readObjectFromXml(String xmlStr) {
|
|
||||||
return readObjectFromXml(new InputSource(StrUtil.getReader(xmlStr)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从XML中读取对象 Reads serialized object from the XML file.<br>
|
|
||||||
* 注意,使用此方法解析不受信任 XML 字符串时,可能容易受到远程代码执行攻击!<br>
|
|
||||||
* 见:https://gitee.com/dromara/hutool/issues/I6AEX2
|
|
||||||
*
|
|
||||||
* @param <T> 对象类型
|
|
||||||
* @param source {@link InputSource}
|
|
||||||
* @return 对象
|
|
||||||
* @since 3.2.0
|
|
||||||
* @deprecated 使用此方法解析不受信任 XML 字符串时,可能容易受到远程代码执行攻击,废弃
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> T readObjectFromXml(InputSource source) {
|
|
||||||
Object result;
|
|
||||||
XMLDecoder xmldec = null;
|
|
||||||
try {
|
|
||||||
xmldec = new XMLDecoder(source);
|
|
||||||
result = xmldec.readObject();
|
|
||||||
} finally {
|
|
||||||
IoUtil.close(xmldec);
|
|
||||||
}
|
|
||||||
return (T) result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------- Write
|
// -------------------------------------------------------------------------------------- Write
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user