mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix: 修复 XmlUtil 中转义/反转义方法错误调用 html4 转义/反转义方法的问题。html4 转义会将中文双引号等字符转义为 xml 无法识别的字符,从而导致解析 xml 时出现异常
This commit is contained in:
parent
8c81e43a07
commit
307670b50d
@ -956,6 +956,7 @@ public class XmlUtil {
|
||||
* < (小于) 替换为 &lt;
|
||||
* > (大于) 替换为 &gt;
|
||||
* " (双引号) 替换为 &quot;
|
||||
* ' (单引号) 替换为 &apos;
|
||||
* </pre>
|
||||
*
|
||||
* @param string 被替换的字符串
|
||||
@ -963,7 +964,7 @@ public class XmlUtil {
|
||||
* @since 4.0.8
|
||||
*/
|
||||
public static String escape(String string) {
|
||||
return EscapeUtil.escapeHtml4(string);
|
||||
return EscapeUtil.escapeXml(string);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -975,7 +976,7 @@ public class XmlUtil {
|
||||
* @since 5.0.6
|
||||
*/
|
||||
public static String unescape(String string) {
|
||||
return EscapeUtil.unescapeHtml4(string);
|
||||
return EscapeUtil.unescapeXml(string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -320,6 +320,7 @@ public class XmlUtilTest {
|
||||
final String a = "<>";
|
||||
final String escape = XmlUtil.escape(a);
|
||||
Console.log(escape);
|
||||
Console.log(XmlUtil.escape("中文“双引号”"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user