Merge remote-tracking branch 'origin/v5-dev' into v5-dev

This commit is contained in:
wenlianggong 2024-06-25 20:43:23 +08:00
commit 9ddb271f2e
6 changed files with 48 additions and 5 deletions

View File

@ -2,7 +2,7 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.8.29(2024-06-18)
# 5.8.29(2024-06-21)
### 🐣新特性
* 【core 】 DateUtil增加offsetYear方法
@ -22,6 +22,8 @@
* 【core 】 修复DateUtil.offset空指针问题issue#3617@Github
* 【core 】 修复PathMover.moveContent问题issue#IA5Q8D@Gitee
* 【db 】 修复PooledConnection可能的数据库驱动未找到问题issue#IA6EUQ@Gitee
* 【http 】 修复Mac下的微信浏览器被识别为移动端问题issue#IA74K2@Gitee
* 【core 】 修复Tailer指定初始读取行数的计算错误问题issue#IA77ML@Gitee
-------------------------------------------------------------------------------------------------------------
# 5.8.28(2024-05-29)

View File

@ -68,7 +68,7 @@ public class Tailer implements Serializable {
*
* @param file 文件
* @param lineHandler 行处理器
* @param initReadLine 启动时预读取的行数
* @param initReadLine 启动时预读取的行数1表示一行
*/
public Tailer(File file, LineHandler lineHandler, int initReadLine) {
this(file, CharsetUtil.CHARSET_UTF_8, lineHandler, initReadLine, DateUnit.SECOND.getMillis());
@ -91,7 +91,7 @@ public class Tailer implements Serializable {
* @param file 文件
* @param charset 编码
* @param lineHandler 行处理器
* @param initReadLine 启动时预读取的行数
* @param initReadLine 启动时预读取的行数1表示一行
* @param period 检查间隔
*/
public Tailer(File file, Charset charset, LineHandler lineHandler, int initReadLine, long period) {
@ -197,7 +197,9 @@ public class Tailer implements Serializable {
int currentLine = 0;
while (nextEnd > start) {
//
if (currentLine > initReadLine) {
if (currentLine >= initReadLine) {
// issue#IA77ML initReadLine是行数从1开始currentLine是行号从0开始
// 因此行号0表示一行所以currentLine == initReadLine表示读取完毕
break;
}

View File

@ -8,6 +8,7 @@ import cn.hutool.crypto.ECKeyUtil;
import cn.hutool.crypto.KeyUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.SmUtil;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.engines.SM2Engine;
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
import org.bouncycastle.jcajce.spec.OpenSSHPrivateKeySpec;
@ -336,4 +337,11 @@ public class SM2Test {
String publicKey = "04bf347dfa32b9bc4c378232898ea43a210887a9b9ed6cc188f91b653706b44fa8434518d54412606788f34be8097cc233608f780edaf695c7e2b1d1c1b7b0d7c3";
new SM2(null, publicKey);
}
@Test(expected = DataLengthException.class)
public void issueIA824PTest() {
SM2 sm2 = SmUtil.sm2();
String emptyStr = "";
sm2.encryptHex(emptyStr, KeyType.PublicKey);
}
}

View File

@ -104,4 +104,14 @@ public class OS extends UserAgentInfo {
}
return ReUtil.getGroup1(this.versionPattern, userAgentString);
}
/**
* 是否为MacOS
*
* @return 是否为MacOS
* @since 5.8.29
*/
public boolean isMacOS(){
return "OSX".equals(getName());
}
}

View File

@ -40,7 +40,13 @@ public class UserAgentParser {
// 平台
final Platform platform = parsePlatform(userAgentString);
userAgent.setPlatform(platform);
userAgent.setMobile(platform.isMobile() || browser.isMobile());
// issue#IA74K2 MACOS下的微信不属于移动平台
if(platform.isMobile() || browser.isMobile()){
if(false == os.isMacOS()){
userAgent.setMobile(true);
}
}
return userAgent;

View File

@ -488,4 +488,19 @@ public class UserAgentUtilTest {
Assert.assertEquals("Windows", ua2.getPlatform().toString());
Assert.assertFalse(ua2.isMobile());
}
@Test
public void issueIA74K2Test() {
UserAgent ua = UserAgentUtil.parse(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) MicroMessenger/6.8.0(0x16080000) MacWechat/3.8.7(0x13080710) Safari/605.1.15 NetType/WIFI");
Assert.assertEquals("MicroMessenger", ua.getBrowser().toString());
Assert.assertEquals("6.8.0", ua.getVersion());
Assert.assertEquals("Webkit", ua.getEngine().toString());
Assert.assertEquals("605.1.15", ua.getEngineVersion());
Assert.assertEquals("OSX", ua.getOs().toString());
Assert.assertEquals("10_15_7", ua.getOsVersion());
Assert.assertEquals("Mac", ua.getPlatform().toString());
Assert.assertFalse(ua.isMobile());
}
}