修复数字解析错误

This commit is contained in:
xuncha
2026-02-05 17:58:38 +08:00
committed by xuncha
parent ff2f6799c8
commit d7419669d6
4 changed files with 11 additions and 4 deletions

View File

@@ -193,7 +193,9 @@ class AnnualReportService {
if (!raw) return ''
if (typeof raw === 'string') {
if (raw.length === 0) return ''
if (this.looksLikeHex(raw)) {
// 只有当字符串足够长超过16字符且看起来像 hex 时才尝试解码
// 短字符串(如 "123456" 等纯数字)容易被误判为 hex
if (raw.length > 16 && this.looksLikeHex(raw)) {
const bytes = Buffer.from(raw, 'hex')
if (bytes.length > 0) return this.decodeBinaryContent(bytes)
}