This commit is contained in:
Looly
2022-11-28 13:52:11 +08:00
parent 738519d6db
commit 9e6ba78ae8
3 changed files with 18 additions and 5 deletions

View File

@@ -135,6 +135,16 @@ public class HtmlUtilTest {
Assert.assertEquals("'", HtmlUtil.unescape("'"));
}
@Test
public void escapeTest2() {
final char c = ' '; // 不断开空格non-breaking space缩写nbsp。)
Assert.assertEquals(c, 160);
final String html = "<html><body> </body></html>";
final String escape = HtmlUtil.escape(html);
Assert.assertEquals("&lt;html&gt;&lt;body&gt;&nbsp;&lt;/body&gt;&lt;/html&gt;", escape);
Assert.assertEquals(" ", HtmlUtil.unescape("&nbsp;"));
}
@Test
public void filterTest() {
final String html = "<alert></alert>";