diff --git a/hutool-core/src/test/java/org/dromara/hutool/core/net/UrlBuilderTest.java b/hutool-core/src/test/java/org/dromara/hutool/core/net/UrlBuilderTest.java index 58b2e312b..31d181899 100644 --- a/hutool-core/src/test/java/org/dromara/hutool/core/net/UrlBuilderTest.java +++ b/hutool-core/src/test/java/org/dromara/hutool/core/net/UrlBuilderTest.java @@ -518,4 +518,15 @@ public class UrlBuilderTest { final String build = httpUrl.build(CharsetUtil.UTF_8); assertEquals("/a:1/b:1/c:1/d:1/", build); } + + @Test + public void issueIAAOC1Test() { + // 使用默认编码后,会先decode给定的URL,再encode + UrlBuilder urlBuilder = UrlBuilder.ofHttp("http://localhost:9999/getReportDataList?goodsName=工业硫酸98%&conReportTypeId=1"); + assertEquals("http://localhost:9999/getReportDataList?goodsName=%E5%B7%A5%E4%B8%9A%E7%A1%AB%E9%85%B898%25&conReportTypeId=1", urlBuilder.build()); + + // 不指定编码,则保持原字符串 + urlBuilder = UrlBuilder.ofHttp("http://localhost:9999/getReportDataList?goodsName=工业硫酸98%&conReportTypeId=1", null); + assertEquals("http://localhost:9999/getReportDataList?goodsName=工业硫酸98%&conReportTypeId=1", urlBuilder.build()); + } }