mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix escape bug
This commit is contained in:
@@ -12,6 +12,29 @@ public class EscapeUtilTest {
|
||||
|
||||
String result = EscapeUtil.unescapeHtml4("振荡器类型");
|
||||
Assert.assertEquals("振荡器类型", result);
|
||||
|
||||
|
||||
String escape = EscapeUtil.escapeHtml4("*@-_+./(123你好)");
|
||||
Assert.assertEquals("*@-_+./(123你好)", escape);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeTest(){
|
||||
String str = "*@-_+./(123你好)ABCabc";
|
||||
String escape = EscapeUtil.escape(str);
|
||||
Assert.assertEquals("*@-_+./%28123%u4f60%u597d%29ABCabc", escape);
|
||||
|
||||
String unescape = EscapeUtil.unescape(escape);
|
||||
Assert.assertEquals(str, unescape);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeAllTest(){
|
||||
String str = "*@-_+./(123你好)ABCabc";
|
||||
|
||||
String escape = EscapeUtil.escapeAll(str);
|
||||
Assert.assertEquals("%2a%40%2d%5f%2b%2e%2f%28%31%32%33%u4f60%u597d%29%41%42%43%61%62%63", escape);
|
||||
|
||||
String unescape = EscapeUtil.unescape(escape);
|
||||
Assert.assertEquals(str, unescape);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user