fix escape bug

This commit is contained in:
Looly
2021-06-24 07:53:21 +08:00
parent a97e967ecd
commit 949c7a856e
14 changed files with 166 additions and 36 deletions

View File

@@ -4,12 +4,12 @@ import org.junit.Assert;
import org.junit.Test;
public class EscapeUtilTest {
@Test
public void escapeHtml4Test() {
String escapeHtml4 = EscapeUtil.escapeHtml4("<a>你好</a>");
Assert.assertEquals("&lt;a&gt;你好&lt;/a&gt;", escapeHtml4);
String result = EscapeUtil.unescapeHtml4("&#25391;&#33633;&#22120;&#31867;&#22411;");
Assert.assertEquals("振荡器类型", result);
@@ -39,9 +39,9 @@ public class EscapeUtilTest {
}
@Test
public void escapeSinleQuotesTest(){
public void escapeSingleQuotesTest(){
String str = "'some text with single quotes'";
final String s = EscapeUtil.escapeHtml4(str);
Assert.assertEquals(str, s);
Assert.assertEquals("&apos;some text with single quotes&apos;", s);
}
}

View File

@@ -287,4 +287,11 @@ public class XmlUtilTest {
String format = XmlUtil.toStr(xml,"GBK",true);
Console.log(format);
}
@Test
public void escapeTest(){
String a = "<>";
final String escape = XmlUtil.escape(a);
Console.log(escape);
}
}