mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
Compare commits
3 Commits
a32fac8760
...
80fe1c8877
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80fe1c8877 | ||
|
|
2ba1b4d649 | ||
|
|
5c236d04e1 |
@@ -1,13 +1,14 @@
|
||||
|
||||
# 🚀Changelog
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.44(2026-01-12)
|
||||
# 5.8.44(2026-01-18)
|
||||
### 🐣新特性
|
||||
* 【core 】 `NumberUtil.parseNumber`增加支持科学计数法(pr#4211@Github)
|
||||
* 【captcha】 `AbstractCaptcha`增加`setStroke`方法支持线条粗细(issue#IDJQ15@Gitee)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【json 】 修复`JSONUtil.wrap`忽略错误问题(issue#4210@Github)
|
||||
* 【http 】 修复`HttpUtil.normalizeParams `在极端输入下抛 StringIndexOutOfBoundsException(pr#4216@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.43(2026-01-04)
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.StreamProgress;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.net.RFC3986;
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
@@ -580,9 +581,11 @@ public class HttpUtil {
|
||||
}
|
||||
|
||||
// 以&结尾则去除之
|
||||
int lastIndex = builder.length() - 1;
|
||||
if ('&' == builder.charAt(lastIndex)) {
|
||||
builder.delTo(lastIndex);
|
||||
if (!builder.isEmpty()) {
|
||||
int lastIndex = builder.length() - 1;
|
||||
if ('&' == builder.charAt(lastIndex)) {
|
||||
builder.delTo(lastIndex);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
@@ -883,6 +886,8 @@ public class HttpUtil {
|
||||
* @since 5.4.6
|
||||
*/
|
||||
public static String buildBasicAuth(String username, String password, Charset charset) {
|
||||
Assert.notNull(username, "username must not be null");
|
||||
Assert.notNull(password, "password must not be null");
|
||||
final String data = username.concat(":").concat(password);
|
||||
return "Basic " + Base64.encode(data, charset);
|
||||
}
|
||||
|
||||
@@ -327,6 +327,12 @@ public class HttpUtilTest {
|
||||
assertEquals("", encodeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normalizEampersandParamsTest() {
|
||||
final String encodeResult = HttpUtil.normalizeParams("&", CharsetUtil.CHARSET_UTF_8);
|
||||
assertEquals("", encodeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMimeTypeTest() {
|
||||
final String mimeType = HttpUtil.getMimeType("aaa.aaa");
|
||||
|
||||
Reference in New Issue
Block a user