diff --git a/CHANGELOG.md b/CHANGELOG.md index 60e2764a2..787ce7868 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/hutool-core/src/main/java/cn/hutool/core/io/file/Tailer.java b/hutool-core/src/main/java/cn/hutool/core/io/file/Tailer.java index e6a6e16b6..61faef230 100755 --- a/hutool-core/src/main/java/cn/hutool/core/io/file/Tailer.java +++ b/hutool-core/src/main/java/cn/hutool/core/io/file/Tailer.java @@ -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; } diff --git a/hutool-crypto/src/test/java/cn/hutool/crypto/asymmetric/SM2Test.java b/hutool-crypto/src/test/java/cn/hutool/crypto/asymmetric/SM2Test.java index b007642c2..ad78cfc57 100644 --- a/hutool-crypto/src/test/java/cn/hutool/crypto/asymmetric/SM2Test.java +++ b/hutool-crypto/src/test/java/cn/hutool/crypto/asymmetric/SM2Test.java @@ -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); + } } diff --git a/hutool-http/src/main/java/cn/hutool/http/useragent/OS.java b/hutool-http/src/main/java/cn/hutool/http/useragent/OS.java index 965d851d3..38a956c58 100755 --- a/hutool-http/src/main/java/cn/hutool/http/useragent/OS.java +++ b/hutool-http/src/main/java/cn/hutool/http/useragent/OS.java @@ -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()); + } } diff --git a/hutool-http/src/main/java/cn/hutool/http/useragent/UserAgentParser.java b/hutool-http/src/main/java/cn/hutool/http/useragent/UserAgentParser.java index d0f2a7fc3..476ec42b3 100644 --- a/hutool-http/src/main/java/cn/hutool/http/useragent/UserAgentParser.java +++ b/hutool-http/src/main/java/cn/hutool/http/useragent/UserAgentParser.java @@ -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; diff --git a/hutool-http/src/test/java/cn/hutool/http/useragent/UserAgentUtilTest.java b/hutool-http/src/test/java/cn/hutool/http/useragent/UserAgentUtilTest.java index 42142a73b..cc2814477 100644 --- a/hutool-http/src/test/java/cn/hutool/http/useragent/UserAgentUtilTest.java +++ b/hutool-http/src/test/java/cn/hutool/http/useragent/UserAgentUtilTest.java @@ -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()); + } }