mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
html防止注入转译,增加不断开空格(nbsp)转译
This commit is contained in:
@@ -134,6 +134,16 @@ public class HtmlUtilTest {
|
||||
Assert.assertEquals("'", HtmlUtil.unescape("'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeTest2() {
|
||||
char c = ' '; // 不断开空格(non-breaking space,缩写nbsp。)
|
||||
Assert.assertEquals(c, 160);
|
||||
String html = "<html><body> </body></html>";
|
||||
String escape = HtmlUtil.escape(html);
|
||||
Assert.assertEquals("<html><body> </body></html>", escape);
|
||||
Assert.assertEquals(" ", HtmlUtil.unescape(" "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterTest() {
|
||||
String html = "<alert></alert>";
|
||||
|
Reference in New Issue
Block a user