Repository navigation
Conversation
Contributor
Welcome To opensourceways CommunityHey @fly333sky , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. Contact GuideIf you have any questions, please contact the SIG: infratructure , |
Contributor
CLA Signature Passfly333sky, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
Contributor
|
|||||||||||||
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.
背景
[需求] CLA邮件通知,能展示双语(中文+英文)(app-cla-server)· 开发流水线 · 开发预览阶段(代码已推 + 预览已部署 + UT 已补;门禁/对抗由 PR CI 异步跑)
改动内容
fix(app-cla-server): NormalizeLang 大小写不敏感,修复个人签署中文邮件渲染为英文
问题
review 指出:
controllers/individual_signing.go:85个人签署完成邮件直接用未经规范化的原始请求值
info.CLALanguage作为Lang。签署流程对语言大小写不敏感地接受(
dp.NewLanguage→config.getLanguage用strings.ToLower归一,"chinese"/"CHINESE"均签署成功入库为 "Chinese"),但
emailtmpl.NormalizeLang仅识别精确串"Chinese"/"English"/"zh"/"en",对其余大小写变体一律兜底 en。
后果:客户端以小写或非规范大小写提交
cla_language=chinese时,签署按中文成功落库,完成通知邮件却渲染成英文,违反验收标准 1。
修复
采用 review 建议的方案 (b):把
emailtmpl.NormalizeLang改为大小写不敏感(
switch strings.ToLower(v):chinese/zh→zh、english/en→en、其余→en),从根上消除全部路径的大小写隐患。
NormalizeLang是genEmailMsg(template.go:120)的唯一语言归一入口,所有 21 类邮件渲染均经此函数;
watch/notify_corp_admin.go的审计日志(line 267/479)也调用它。因此只需改这一处,即覆盖全部发信路径(含 individual_signing),无需逐个 controller 改。
变更文件
signing/infrastructure/emailtmpl/template.gostringsimportNormalizeLang:switch v→switch strings.ToLower(v),case 由
"Chinese"/"English"改为"chinese"/"english"signing/infrastructure/emailtmpl/template_test.goTestNormalizeLang:修正原编码 buggy 行为的用例{"chinese", langEN}→langZHCHINESE→zh、ChInEsE→zh、english→en、ZH→zh、EN→en验证
go build ./...通过go vet ./signing/infrastructure/emailtmpl/...通过go test -cover ./signing/infrastructure/emailtmpl/...全绿,覆盖率 91.4%UT 补充
signing/infrastructure/emailtmpl/template_test.goTestNormalizeLang覆盖了大小写不敏感归一的全部分支——正常路径(Chinese/English/zh/en)、大小写变体(chinese/CHINESE/ChInEsE/english/ENGLISH/ZH/EN)、
兜底路径(空串、未知值 xx)。
相关 Issue
resolve https://github.com/opensourceways/backlog/issues/2797
AI 使用声明
当前 PR 是否有 AI 参与:
/ai-develop-preview