diff --git a/CHANGELOG.md b/CHANGELOG.md index d59af9457..3e255206f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.24(2023-12-19) +# 5.8.24(2023-12-20) ### 🐣新特性 * 【cache 】 Cache增加get重载,可自定义超时时间(issue#I8G0DL@Gitee) @@ -14,6 +14,7 @@ * 【core 】 DateUtil.parse支持毫秒时间戳(issue#I8NMP7@Gitee) * 【extra 】 优化TokenizerEngine使用IK分词器支持并发(pr#3427@Github) * 【core 】 Opt.ofEmptyAble支持更多类型(issue#I8OOSY@Gitee) +* 【http 】 HTMLFilter保留p标签(issue#3433@Gitee) ### 🐞Bug修复 * 【core 】 修复LocalDateTime#parseDate未判断空问题问题(issue#I8FN7F@Gitee) diff --git a/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java b/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java index ffed78541..3bfaee3a5 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java +++ b/hutool-http/src/main/java/cn/hutool/http/HTMLFilter.java @@ -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"}; diff --git a/hutool-http/src/test/java/cn/hutool/http/HTMLFilterTest.java b/hutool-http/src/test/java/cn/hutool/http/HTMLFilterTest.java new file mode 100644 index 000000000..03045a9a7 --- /dev/null +++ b/hutool-http/src/test/java/cn/hutool/http/HTMLFilterTest.java @@ -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 = "

a

"; + String p2 = "

a

"; + + final HTMLFilter htmlFilter = new HTMLFilter(); + String filter = htmlFilter.filter(p1); + Assert.assertEquals("

a

", filter); + + filter = htmlFilter.filter(p2); + Assert.assertEquals("

a

", filter); + } +}