mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add unescape
This commit is contained in:
parent
4899e03a48
commit
5b283651b0
@ -22,6 +22,7 @@
|
|||||||
* 【http 】 SoapClient增加addSOAPHeader方法
|
* 【http 】 SoapClient增加addSOAPHeader方法
|
||||||
* 【http 】 完善StrUtil的注释(pr#186@Gitee)
|
* 【http 】 完善StrUtil的注释(pr#186@Gitee)
|
||||||
* 【aop 】 去除调试日志(issue#1116@Github)
|
* 【aop 】 去除调试日志(issue#1116@Github)
|
||||||
|
* 【core 】 增加'反转义(pr#1121@Github)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【crypto 】 修复SM2验签后无法解密问题(issue#I1W0VP@Gitee)
|
* 【crypto 】 修复SM2验签后无法解密问题(issue#I1W0VP@Gitee)
|
||||||
|
@ -18,7 +18,6 @@ public class Html4Escape extends ReplacerChain {
|
|||||||
{ "&", "&" }, // & - ampersand
|
{ "&", "&" }, // & - ampersand
|
||||||
{ "<", "<" }, // < - less-than
|
{ "<", "<" }, // < - less-than
|
||||||
{ ">", ">" }, // > - greater-than
|
{ ">", ">" }, // > - greater-than
|
||||||
{"\'", "'"} // ' - quote
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected static final String[][] ISO8859_1_ESCAPE = { //
|
protected static final String[][] ISO8859_1_ESCAPE = { //
|
||||||
|
@ -15,11 +15,14 @@ public class Html4Unescape extends ReplacerChain {
|
|||||||
protected static final String[][] BASIC_UNESCAPE = InternalEscapeUtil.invert(Html4Escape.BASIC_ESCAPE);
|
protected static final String[][] BASIC_UNESCAPE = InternalEscapeUtil.invert(Html4Escape.BASIC_ESCAPE);
|
||||||
protected static final String[][] ISO8859_1_UNESCAPE = InternalEscapeUtil.invert(Html4Escape.ISO8859_1_ESCAPE);
|
protected static final String[][] ISO8859_1_UNESCAPE = InternalEscapeUtil.invert(Html4Escape.ISO8859_1_ESCAPE);
|
||||||
protected static final String[][] HTML40_EXTENDED_UNESCAPE = InternalEscapeUtil.invert(Html4Escape.HTML40_EXTENDED_ESCAPE);
|
protected static final String[][] HTML40_EXTENDED_UNESCAPE = InternalEscapeUtil.invert(Html4Escape.HTML40_EXTENDED_ESCAPE);
|
||||||
|
// issue#1118
|
||||||
|
protected static final String[][] OTHER_UNESCAPE = new String[][]{new String[]{"'", "'"}};
|
||||||
|
|
||||||
public Html4Unescape() {
|
public Html4Unescape() {
|
||||||
addChain(new LookupReplacer(BASIC_UNESCAPE));
|
addChain(new LookupReplacer(BASIC_UNESCAPE));
|
||||||
addChain(new LookupReplacer(ISO8859_1_UNESCAPE));
|
addChain(new LookupReplacer(ISO8859_1_UNESCAPE));
|
||||||
addChain(new LookupReplacer(HTML40_EXTENDED_UNESCAPE));
|
addChain(new LookupReplacer(HTML40_EXTENDED_UNESCAPE));
|
||||||
|
addChain(new LookupReplacer(OTHER_UNESCAPE));
|
||||||
addChain(new NumericEntityUnescaper());
|
addChain(new NumericEntityUnescaper());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class HtmlUtilTest {
|
|||||||
Assert.assertEquals("<html><body>123'123'</body></html>", escape);
|
Assert.assertEquals("<html><body>123'123'</body></html>", escape);
|
||||||
String restoreEscaped = HtmlUtil.unescape(escape);
|
String restoreEscaped = HtmlUtil.unescape(escape);
|
||||||
Assert.assertEquals(html, restoreEscaped);
|
Assert.assertEquals(html, restoreEscaped);
|
||||||
Assert.assertEquals("\'", HtmlUtil.unescape("'"));
|
Assert.assertEquals("'", HtmlUtil.unescape("'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user