fix escape bug

This commit is contained in:
Looly
2020-02-28 14:22:16 +08:00
parent 83d6428db8
commit fbfb124f11
5 changed files with 86 additions and 28 deletions

View File

@@ -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);
}
}