mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
HTMLFilter保留p标签
This commit is contained in:
@@ -137,6 +137,7 @@ public final class HTMLFilter {
|
||||
vAllowed.put("strong", no_atts);
|
||||
vAllowed.put("i", no_atts);
|
||||
vAllowed.put("em", no_atts);
|
||||
vAllowed.put("p", no_atts);
|
||||
|
||||
vSelfClosingTags = new String[]{"img"};
|
||||
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
|
||||
|
19
hutool-http/src/test/java/cn/hutool/http/HTMLFilterTest.java
Normal file
19
hutool-http/src/test/java/cn/hutool/http/HTMLFilterTest.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package cn.hutool.http;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HTMLFilterTest {
|
||||
@Test
|
||||
public void issue3433Test() {
|
||||
String p1 = "<p>a</p>";
|
||||
String p2 = "<p onclick=\"bbbb\">a</p>";
|
||||
|
||||
final HTMLFilter htmlFilter = new HTMLFilter();
|
||||
String filter = htmlFilter.filter(p1);
|
||||
Assert.assertEquals("<p>a</p>", filter);
|
||||
|
||||
filter = htmlFilter.filter(p2);
|
||||
Assert.assertEquals("<p>a</p>", filter);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user