mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2026-05-29 18:57:11 +08:00
修复VersionUtil比对null时结果异常问题(issue#IJNFQZ@Gitee)
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
* 【extra 】 修复`ExpressionEngine`中SpELEngine、MVEL白名单无效问题(issue#4249@Github)
|
||||
* 【core 】 修复`JNDIUtil`远程加载漏洞(issue#4249@Github)
|
||||
* 【core 】 修复`ValidateObjectInputStream`白名单规则问题(issue#4249@Github)
|
||||
* 【core 】 修复`VersionUtil`比对null时结果异常问题(issue#IJNFQZ@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.44(2026-03-11)
|
||||
|
||||
@@ -142,7 +142,7 @@ public class VersionUtil {
|
||||
throw new UtilException("非法的版本分隔符:" + versionsDelimiter);
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(versionEl) || StrUtil.isBlank(currentVersion)) {
|
||||
if (StrUtil.isBlank(versionEl)) {
|
||||
return false;
|
||||
}
|
||||
String trimmedVersion = StrUtil.trim(currentVersion);
|
||||
@@ -158,6 +158,9 @@ public class VersionUtil {
|
||||
if (matcher.find()) {
|
||||
String op = matcher.group();
|
||||
String ver = StrUtil.removePrefix(el, op);
|
||||
if("null".equalsIgnoreCase( ver)){
|
||||
ver = null;
|
||||
}
|
||||
switch (op) {
|
||||
case ">=":
|
||||
case "≥":
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.comparator.VersionComparator;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -104,4 +105,10 @@ class VersionUtilTest {
|
||||
assertTrue(VersionUtil.matchEl("999.999.999", "-"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueIJNFQZTest(){
|
||||
assertEquals(1, VersionComparator.INSTANCE.compare("1.0", null));
|
||||
assertEquals(1, StrUtil.compareVersion("1.0", null));
|
||||
assertTrue(VersionUtil.isGreaterThan("1.0", null));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user