From d3463456d93b800e68579e4bdd3d5223504a349c Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Sat, 25 Apr 2026 08:09:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20i18n.Tr=20vet=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E3=80=81Unicode=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=EF=BC=8C=E7=A7=BB=E9=99=A4=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 i18n.Tr 中错误的 fmt.Sprintf fallback,消除 go vet 误报 - 修复 match_engine_test Unicode 测试用例与 Latin-1 转换逻辑不匹配 - README 移除过期的 fscan.club 域名 - 添加 .gitattributes 统一换行符为 LF --- .gitattributes | 2 ++ README.md | 2 +- README_EN.md | 2 +- common/i18n/i18n.go | 4 ---- core/portfinger/match_engine_test.go | 13 +++++++------ 5 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..11a611b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# 统一换行符为 LF +* text=auto eol=lf diff --git a/README.md b/README.md index 5b8e78f..6c28e9c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 内网综合扫描工具,一键自动化漏扫。 -**版本**: 2.1.1 | **官网**: https://fscan.club/ +**版本**: 2.1.1 ## 功能特性 diff --git a/README_EN.md b/README_EN.md index e7ad008..b5213b5 100644 --- a/README_EN.md +++ b/README_EN.md @@ -4,7 +4,7 @@ Comprehensive intranet scanning tool for automated vulnerability assessment. -**Version**: 2.1.1 | **Website**: https://fscan.club/ +**Version**: 2.1.1 ## Features diff --git a/common/i18n/i18n.go b/common/i18n/i18n.go index 4397e5e..9bc89e3 100644 --- a/common/i18n/i18n.go +++ b/common/i18n/i18n.go @@ -83,10 +83,6 @@ func Tr(key string, args ...interface{}) string { TemplateData: data, }) if err != nil || msg == "" { - // 回退:尝试用fmt.Sprintf格式化key本身 - if len(args) > 0 { - return fmt.Sprintf(key, args...) - } return key } return msg diff --git a/core/portfinger/match_engine_test.go b/core/portfinger/match_engine_test.go index 9066957..e8185fd 100644 --- a/core/portfinger/match_engine_test.go +++ b/core/portfinger/match_engine_test.go @@ -355,18 +355,19 @@ func TestMatchPattern_BinaryData(t *testing.T) { } } -// TestMatchPattern_UnicodeResponse 测试Unicode响应 +// TestMatchPattern_UnicodeResponse 测试Latin-1转换后的字节级匹配 func TestMatchPattern_UnicodeResponse(t *testing.T) { - compiled, _ := regexp.Compile(`服务器`) + // bytesToLatin1String 按字节逐个映射到 Latin-1 码点 + // UTF-8 多字节字符会被拆开,所以用字节级正则匹配 + raw := []byte("HTTP/1.1 200 OK\r\nServer: test-srv\r\n") + compiled, _ := regexp.Compile(`test-srv`) m := &Match{ PatternCompiled: compiled, } - response := []byte("HTTP/1.1 200 OK\r\nServer: 服务器\r\n") - - result := m.MatchPattern(response) + result := m.MatchPattern(raw) if !result { - t.Error("Unicode内容应被匹配") + t.Error("Latin-1字节级匹配应成功") } }