mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复getMultistageReverseProxyIp未去除空格问题
This commit is contained in:
parent
d8283fedb0
commit
0d495e34b3
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.8.11.M1 (2022-11-29)
|
# 5.8.11.M1 (2022-12-05)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【core 】 CharUtil.isBlankChar增加\u180e(pr#2738@Github)
|
* 【core 】 CharUtil.isBlankChar增加\u180e(pr#2738@Github)
|
||||||
@ -18,6 +18,7 @@
|
|||||||
* 【core 】 修复HexUtil.isHexNumber()判断逻辑超出long的精度问题(issue#I62H7K@Gitee)
|
* 【core 】 修复HexUtil.isHexNumber()判断逻辑超出long的精度问题(issue#I62H7K@Gitee)
|
||||||
* 【core 】 修复BiMap中未重写computeIfAbsent和putIfAbsent导致双向查找出问题(issue#I62X8O@Gitee)
|
* 【core 】 修复BiMap中未重写computeIfAbsent和putIfAbsent导致双向查找出问题(issue#I62X8O@Gitee)
|
||||||
* 【json 】 修复JSON解析栈溢出部分问题(issue#2746@Github)
|
* 【json 】 修复JSON解析栈溢出部分问题(issue#2746@Github)
|
||||||
|
* 【json 】 修复getMultistageReverseProxyIp未去除空格问题(issue#I64P9J@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -751,9 +751,9 @@ public class NetUtil {
|
|||||||
*/
|
*/
|
||||||
public static String getMultistageReverseProxyIp(String ip) {
|
public static String getMultistageReverseProxyIp(String ip) {
|
||||||
// 多级反向代理检测
|
// 多级反向代理检测
|
||||||
if (ip != null && ip.indexOf(",") > 0) {
|
if (ip != null && StrUtil.indexOf(ip, ',') > 0) {
|
||||||
final String[] ips = ip.trim().split(",");
|
final List<String> ips = StrUtil.splitTrim(ip, ',');
|
||||||
for (String subIp : ips) {
|
for (final String subIp : ips) {
|
||||||
if (false == isUnknown(subIp)) {
|
if (false == isUnknown(subIp)) {
|
||||||
ip = subIp;
|
ip = subIp;
|
||||||
break;
|
break;
|
||||||
|
@ -112,4 +112,11 @@ public class NetUtilTest {
|
|||||||
Assert.assertFalse(NetUtil.isInRange("114.114.114.114","192.168.3.4/32"));
|
Assert.assertFalse(NetUtil.isInRange("114.114.114.114","192.168.3.4/32"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void issueI64P9JTest() {
|
||||||
|
// 获取结果应该去掉空格
|
||||||
|
final String ips = "unknown, 12.34.56.78, 23.45.67.89";
|
||||||
|
final String ip = NetUtil.getMultistageReverseProxyIp(ips);
|
||||||
|
Assert.assertEquals("12.34.56.78", ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user