fix: 修复全仓库代码审查发现的 bug - #47
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
对全仓库进行代码审查后,修复了发现的所有 bug(高危、中危、低危均已处理),并为核心修复补充了回归测试。
修复清单
core(工具类)
FileUtil.isImage:原逻辑取反导致jpg/png/gif返回false;git拼写错误修正为gif,并改用equalsIgnoreCase。TimeUtil.getLeftTimeString:重写为整除/取余一次性计算,修复溢出、错误单位换算等问题;<=0返回"0秒"。TimeUtil.DATE_PATTERN:去掉前导空格" HH:mm:ss"→"HH:mm:ss"。SerializeUtil:改用ISO_8859_1保证任意字节与 char 1:1 往返,避免 UTF-8 损坏序列化数据。RegExUtil.splitTags / regMatchAll2Array:用List收集后再转数组,修复m.groupCount()误当匹配数导致的ArrayIndexOutOfBoundsException。CastUtil.isNumeric:改用BigDecimal严格校验,修复1.2.3、1e3等抛异常/结果错误;负整数仍返回 1、前导+返回 0、非数字/空返回 0。StringUtil.getIP:处理X-Forwarded-For逗号列表取真实客户端地址并跳过unknown,修复反代场景下取 IP 出错的 bug。StringUtil.decode:尾部残缺的%/%u转义原样保留,不再越界抛异常。StringUtil模板 replace/format:缺失 key 保留原占位符;Matcher.quoteReplacement避免$/\被误解析。SqlUtil.delSQlString:null/空输入返回"in()"。Md5Util:getBytes()显式指定 UTF-8,避免平台默认编码不一致。ExcelUtil:公式单元格分别尝试字符串/数值,避免类型不匹配抛异常。MailUtil:改为从 classpath 读取配置;删除拼接明文密码激活链接的redirectValidateUrl。website
@RequestParam接收 FreeMarker 表单 POST(email/password),兼容前端流程。validateEmail端点。CommonDao.delete:游离态实体先merge再remove,避免IllegalArgumentException。website MailUtil.getContent:去掉password参数,激活链接不再携带密码。crawler
OnnmyoujiSpider:所有select().get(i)增加空集合/空串防护;getShikigami增加 try/catch 并在解析失败时返回 null;列表过滤 null 项。socket
MyWebSocket.onMessage:群发前对用户消息做HtmlUtil.htmlEncode,防止 XSS。测试与验证
core/src/test/java/info/xiaomo/core/utils/UtilsBugFixTest.java(11 个用例),覆盖上述关键修复。mvn -B --no-transfer-progress -pl core test:17 个测试全部通过。mvn -B --no-transfer-progress install:全仓库 31 个模块 BUILD SUCCESS。